-
Notifications
You must be signed in to change notification settings - Fork 5.9k
feat(pdf-EPUB): add PDF to EPUB/AZW3 conversion functionality via Calibre #4947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Added the endpoint to EndpointConfiguration - Tests - Controller etc... Signed-off-by: Balázs Szücs <[email protected]>
…version Signed-off-by: Balázs Szücs <[email protected]>
Signed-off-by: Balázs Szücs <[email protected]>
🚀 Translation Verification Summary🔄 Reference Branch:
|
Signed-off-by: Balázs Szücs <[email protected]>
Signed-off-by: Balázs Szücs <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new PDF to EPUB/AZW3 conversion feature using Calibre, enabling users to convert PDF documents into reflowable e-book formats optimized for e-readers.
Key changes include:
- Backend conversion controller with configurable chapter detection and device-specific optimization profiles
- Request model supporting EPUB/AZW3 output formats and device targeting (tablet/e-ink)
- New UI template with conversion options and comprehensive test coverage
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ConvertPDFToEpubController.java | New controller implementing PDF to EPUB/AZW3 conversion using Calibre with heuristic processing and CSS filtering |
| ConvertPdfToEpubRequest.java | Request model defining conversion parameters including output format, device profile, and chapter detection |
| ConverterWebController.java | Added web endpoint for pdf-to-epub form view |
| EndpointConfiguration.java | Registered pdf-to-epub endpoint in Convert and Calibre groups |
| pdf-to-epub.html | New UI template with upload form and conversion options |
| ebook-to-pdf.html | Code formatting cleanup for consistency (removed extra whitespace from attributes) |
| navElements.html | Added navigation entries for pdf-to-epub tool |
| messages_en_GB.properties | Added localization strings for pdf-to-epub feature |
| ConvertPDFToEpubControllerTest.java | Comprehensive unit tests covering command generation, parameter handling, and cleanup |
| ConverterWebControllerTest.java | Added endpoint enable/disable tests for pdf-to-epub |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
ConvertPDFToEpubControllerto handle the conversion workflow.ConvertPdfToEpubRequestto support new conversion parameters (Device profile and Chapter detection).Frontend & UI
pdf-to-epub.htmlcontaining the upload form and configuration options.navElements.htmlandmessages.propertiesto expose the tool in the navigation menu under the "Convert" group.ebook-to-pdftemplate for consistency.Configuration & Testing
pdf-to-epubendpoint inEndpointConfiguration, placing it under the Calibre dependency group.The conversion process utilizes specific calibre,
ebook-convertflags to ensure high-quality output:--enable-heuristics): Automatically detects and fixes common PDF scanning issues, such as broken lines, hyphens at line ends, and inconsistent paragraph spacing.--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.).--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.Checklist
General
Documentation
Translations (if applicable)
scripts/counter_translation.pyUI Changes (if applicable)
Testing (if applicable)