View Single Post
Old 11-22-2009, 07:49 AM   #1
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,515
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Lightbulb Script for converting ePUB to PDF using Prince

Some time ago I wrote the epub2pdf script to render ePUB files into PDF, using the excellent abilities of Prince.

Well, I think it's about time to have it with its own thread in the ePUB forum

It is tried in Linux only, but I guess it should work in Windows under Cygwin too, and in MacOs. The script uses unzip, XMLstarlet and Prince. These are the usage notes:

Code:
epub2pdf.sh [options] input.epub output.pdf

Where the options are:
  -s "style.css"  Use "style.css" as stylesheet (default is "default.css")
  -S "style.css"  Use "style.css" as highest-priority stylesheet
         Stylesheets will be searched in the current directory first, and then in ~/.epub2pdf
  -v              Verbose output
  -h              Show this help
So you see, it's fairly easy. Place the included "default.css" file in ~/.epub2pdf and it will be used automatically for all conversions, or you can specify other css file (or modify default.css at your will), it will be searched in ~/.epub2pdf first (so you can keep different "profiles" there).

I added a feature to use a book-specific stylesheet if found. This stylesheet should be included in the .epub and referenced thus:

1.- Include a .css with rules and selectors for Prince. These are not going to be used in the normal ePUB rendering, only when processing with Prince, so you can use everything supported by Prince (use !important to override the standard css rules).

2.- As with every file you include in the epub, there must be an entry in the <manifest> (in the .opf file).

3.- Add a <meta name="prince-style" content="XXXXX"> to the <metadata> block of the .opf file, where "XXXXX" is the id of the above .css file.

That's all, epub2pdf will use this .css file included in the .epub in addition to the default.css or whatever you use. The ePUB files I've uploaded here have all this epub2pdf-specific style.

Current version is 3.1

GUI version
Calibre plugin version
Attached Files
File Type: zip epub2pdf.zip (2.9 KB, 2589 views)

Last edited by Jellby; 12-26-2013 at 07:50 AM.
Jellby is offline   Reply With Quote