Saturday, January 11, 2014

Convert .EPUB ebook to .PDF

To convert an .epub file (an ebook) to a PDF, I tried several options:
  • Calibre, great software, but not for conversion to PDF: it doesn't handle top and bottom margins on this type of conversion, so it even cuts characters in half on the output PDF between pages
  • Printing from the Calibre Ebook-viewer to PDF file: works in some ways better than the Calibre conversion itself, but it doesn't handle page breaks
  • CLI (command line interface) use of Calibre's conversion (ebook-convert): works, but I can't manage the parameters well enough from the command line
So finally I found Prince, which works beautifully.

The workflow is:
  • make a copy of your .epub file
  • rename the extension of your copy from .epub to .zip (it is in fact a simple .zip file)
  • extract the .zip file in a directory of your choice
  • navigate to the subdirectory where the text files of your ebook are extracted (the .html and .xhtml ones)
  • use the command
    prince cover.xhtml page_1.html page_2.html page_3.html -o book.pdf
     where you change and add filenames according to your specific case of course.
The output is book.pdf and should look fine.
If I understand correctly, this should work under Ubuntu and Windows alike...

(With thanks to this thread...)

No comments:

Post a Comment