Skip to content

Convert EPUB to PDF from the CLI

Convert an EPUB ebook to PDF from the command line with Calibre’s ebook-convert tool. The basic form is one command; extra flags tighten the output into a denser, textbook-style layout.

Calibre is in the official extra repo, so no AUR is needed. arch/scripts/08-apps.sh installs it; on a machine where that has not run:

Terminal window
sudo pacman -S --needed calibre

Ebook filenames often contain spaces. Change into the folder first and use a *.epub glob so the shell fills in the exact name, which avoids typos and line-break issues.

Terminal window
cd ~/Downloads/book-to-convert
ebook-convert *.epub 'output-name.pdf'

If you prefer to type the source name, start with ebook-convert 'Prob and press Tab for shell completion.

Calibre’s PDF stage defaults to a large base font (around 20pt), which makes the output read like a blog post. Shrink the fonts and margins to tighten it.

Terminal window
cd ~/Downloads/book-to-convert
ebook-convert *.epub 'output-dense.pdf' \
--paper-size a4 \
--pdf-default-font-size 14 \
--pdf-mono-font-size 12 \
--pdf-page-margin-top 24 --pdf-page-margin-bottom 24 \
--pdf-page-margin-left 28 --pdf-page-margin-right 28 \
--minimum-line-height 110 \
--pdf-add-toc
  • –paper-size a4 - page size for the output PDF
  • –pdf-default-font-size - main lever for density; try 12 for tighter text
  • –pdf-mono-font-size - size for code and monospace blocks
  • –pdf-page-margin-top / -bottom / -left / -right - margins in points (36pt = 0.5in)
  • –minimum-line-height - line height as a percent; lower is tighter
  • –pdf-add-toc - adds a generated table-of-contents page (the EPUB’s own TOC also becomes PDF bookmarks automatically)

An EPUB is reflowable HTML with no fixed page layout. The original printed book’s dense, multi-column layout is not stored in the EPUB, so a conversion can never reproduce it: the content reflows into single-column pages. Font and margin tuning helps, but the true original look requires the original PDF.

These appear during conversion and are cosmetic or informational only.

  • Ignoring CSS rule with invalid selector ... :has(...) / ::marker ... not supported - Calibre’s CSS engine skips modern selectors
  • The cover image has an id != "cover". Renaming to work around bug in Nook Color - an informational workaround
  • GPUInfo not initialized on GpuInfoUpdate - Qt/WebEngine chatter
  • Removing fake margins / Cleaning up manifest / Trimming unused files - normal cleanup steps

The full Calibre app can do the same conversion: add the book, choose Convert books, and set the output format to PDF. The CLI above is faster for one-offs.