EPUB is the open standard for ebooks. PDF is the universal document format. Converting between them should be trivial since both contain styled text and images. But the fundamental difference in how they handle layout makes this conversion surprisingly complex.
The fundamental mismatch
EPUB is a reflowable format. The text adapts to the screen size, like a web page. There are no "pages" in an EPUB -- the content flows continuously and the reader application decides where page breaks fall based on the display size.
PDF is a fixed-layout format. Every character has an exact position on a specific page. The layout does not change regardless of the display size. A PDF designed for A4 paper always looks like A4 paper, whether you view it on a phone or a projector.
Converting from reflowable to fixed layout means you must decide: what page size? What margins? What font size? Where do page breaks fall? These decisions do not exist in the EPUB because they are left to the reader.
The conversion process
A proper EPUB-to-PDF conversion follows these steps:
Parse the EPUB: Extract the ZIP, read the OPF manifest, determine the spine (reading order).
Render each chapter: Each chapter is an XHTML file. Render it using an HTML rendering engine with a fixed viewport width matching your target page dimensions.
Paginate: Apply page breaks based on the rendered content height. Avoid breaking in the middle of paragraphs, images, or tables where possible. This requires a layout engine that understands CSS page-break properties.
Generate PDF: Convert each page to a PDF page. Embed fonts, include images at appropriate resolution, preserve hyperlinks as PDF links.
Common quality problems
Font issues: The EPUB may use system fonts or embed its own. If the conversion tool cannot find or embed the fonts, it substitutes, changing the appearance. Always embed fonts in the output PDF.
Image resolution: EPUB images optimized for screen (72-150 DPI) look blurry when printed from a PDF. There is no way to increase the resolution of existing images, but you can ensure they are not downsampled further during conversion.
Table breaking: Tables that span more than one page need to repeat headers on continuation pages. Most simple converters do not handle this.
Code blocks: Programming books with code blocks need those blocks to stay together and use monospaced fonts. Line breaking in code blocks must respect logical break points.
Table of contents: The EPUB's navigation document should convert to PDF bookmarks for navigation. Without this, the PDF loses its table of contents functionality.
Tools that do it well
Calibre (open source, desktop): The gold standard for ebook conversion. Handles most edge cases correctly. Extensive configuration options. The command-line tool ebook-convert is scriptable.
Pandoc: Converts between many formats including EPUB to PDF. Uses LaTeX for PDF generation, which produces beautiful typography but requires a LaTeX installation.
Browser-based rendering: Using a headless browser (Puppeteer, Playwright) to render each EPUB chapter as HTML and then print to PDF. This leverages the browser's CSS implementation, which is more complete than most dedicated converters.
When not to convert
If the EPUB will only be read on screen, keeping it as EPUB is usually better. The reflowable format provides a better reading experience on phones, tablets, and e-readers. PDF is appropriate when you need print-ready output, archival copies, or distribution to people who do not have an EPUB reader.
The converter
For quick EPUB-to-PDF conversion without installing Calibre, I built an EPUB to PDF converter that handles the rendering and pagination in the browser. Drop in an EPUB, configure your page size preferences, get a PDF.
I'm Michael Lip. I build free developer tools at zovo.one. 500+ tools, all private, all free.
Top comments (0)