mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-12-18 20:04:17 +01:00
# Description of Changes This PR introduces a new conversion tool allowing users to convert PDF documents into EPUB format. This is particularly useful for reading documents on e-readers (like Kindles or Kobos) where standard PDFs often suffer from fixed formatting and unreadable text sizes. The implementation leverages the existing **Calibre** integration (`ebook-convert`) to produce reflowable e-books with specific optimizations for layout and chapter structure. **Backend Implementation** * Added `ConvertPDFToEpubController` to handle the conversion workflow. * Created `ConvertPdfToEpubRequest` to support new conversion parameters (Device profile and Chapter detection). * Integrated standard Stirling-PDF temporary file management and process execution patterns. **Frontend & UI** * Added a new view `pdf-to-epub.html` containing the upload form and configuration options. * Updated `navElements.html` and `messages.properties` to expose the tool in the navigation menu under the "Convert" group. * Minor cleanup of HTML formatting in the existing `ebook-to-pdf` template for consistency. **Configuration & Testing** * Registered the `pdf-to-epub` endpoint in `EndpointConfiguration`, placing it under the **Calibre** dependency group. * Added comprehensive unit tests covering command generation, parameter handling, and temporary file cleanup. The conversion process utilizes specific calibre, `ebook-convert` flags to ensure high-quality output: * **Heuristic Processing** (`--enable-heuristics`): Automatically detects and fixes common PDF scanning issues, such as broken lines, hyphens at line ends, and inconsistent paragraph spacing. * **CSS Filtering** (`--filter-css`): Strips hardcoded styling (font families, fixed margins, colors) from the PDF. This ensures the resulting EPUB respects the user's e-reader settings (font size, dark mode, etc.). * **Smart Chapter Detection** (`--chapter`): Optionally uses an XPath expression (`//h:*[re:test(., '\\s*Chapter\\s+', 'i')]`) to detect headers and insert proper page breaks in the EPUB structure. * **Device Optimization Profiles**: * **Tablet/Phone:** Uses the default profile to maintain image resolution and color. * **Kindle/E-Ink:** Uses a specific profile to resize images and optimize contrast for grayscale screens. <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [X] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [X] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [X] I have performed a self-review of my own code - [X] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [X] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --------- Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> |
||
|---|---|---|
| .. | ||
| common | ||
| core | ||
| proprietary | ||
| allowed-licenses.json | ||