Helllo from Russia! Nice work

. I was used
ebook-convert, but it's very slooow and little bugy. Then i wrote a simple bashscript, but script wasn't smart enough without xml parsing. Until i found your script.
Prince is good, nice ability to adapt file for e-read-devices, but needs to remove logo manually (I'm using "
Master PDF Editor"
http://code-industry.net).
So, i wrote a modification based on your bash script (for my humble printing needs). It uses
Fuse-zip (apt-get install fuse-zip) and
WkHTMLtoPDF (wk means WebKit
http://wkhtmltopdf.org) instead of
Unzip and
Prince. Fuse-zip mounting a little faster then unzip unpacking and
WkHTMLtoPDF have no watermark and it's opensource. But WkHTMLtoPDF have no options for metadata, like in Prince (but i found in your script it doesn't used), and output pdf file size some times a little bigger (may be fonts). To test WkHTMLtoPDF you can try firefox addon "Print pages to PDF", which based on it.
And one sad thing: WkHTMLtoPDF can't print svg cover (cover image in epub usually wrapped in svg tag).
But! I maid a workaround in script (unwrap svg image tag to img tag), and it works, cover prints, but not upscaled to page size.
Dependencies: (in addition to
xmlstarlet and optional(for metadata)
pdftk and
recode):
fuse-zip, wkhtmltopdf, sed.
Options: are same plus 3 additionals:
-n means not load default.css. (Using both -n -S equivalent to use only -s).
-d means don't print cover.
-o accepts wkhtmltopdf options (-o "--grayscale --quiet --page-size A5" Or -o "-gqs A5" Or -o "--page-width 800px --page-height 600px" Or -o "--header-font-name 'Liberation Sans' --footer-font-name 'Liberation Sans'" ...) (By default WkHTMLtoPDF prints to A4 size format).
Already specified WkHTMLtoPDF options can be edited in "
WKHTMLTOPDF OPTIONS SETTINGS" section of script in
set_wkh2popts() function. They are self explained.
And a little fix and improvement of your epub2pdf.sh:
epub2pdf.sh
Cheers!
Just outline how script works:
Code:
## Mount epub archive:
#mkdir "$HOME"/.ZIP
# umount before mount
fusermount -uz "$HOME"/.ZIP
fuse-zip -r "file.epub" "$HOME"/.ZIP -o modules=iconv,from_code=CP866,to_code=UTF8
(iconv here can fix ugly cyrillic filenames in nasty winziped archives)
## Convert html files to pdf
wkhtmltopdf OEBPS/article0.xhtml ... OEBPS/article100.xhtml wkhtmltopdfoutput.pdf
## or:
wkhtmltopdf -l --image-dpi 144 --image-quality 90 -T 5 -R 2 -B 5 -L 2 --user-style-sheet "${HOME}/bin/style.css" cover OEBPS/cover.xhtml OEBPS/article0.xhtml ... OEBPS/article100.xhtml ~/Documents/wkhtmltopdfoutput.pdf
## or even:
wkhtmltopdf --lowquality --image-dpi 144 --image-quality 90 -T 5 -R 2 -B 5 -L 2 --user-style-sheet "${HOME}/bin/style.css" --page-size A5 -O Landscape --load-error-handling ignore --load-media-error-handling ignore --javascript-delay 2500 --header-left '[title]' --header-right '[date]' --header-font-name 'WenQuanYi Micro Hei' --header-font-size 8 --header-line --footer-left '[webpage]' --footer-right '[page] / [topage]' --footer-font-name 'WenQuanYi Micro Hei' --footer-font-size 8 --footer-line --custom-header 'User-Agent' 'Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0' --custom-header-propagation cover OEBPS/cover.xhtml OEBPS/article0.xhtml ... OEBPS/article100.xhtml ~/Documents/wkhtmltopdfoutput.pdf