|
Convert ePub to pdf with pandocRequirements : texlive-texmf-20110705-1-mdv2011.0.noarch lib64ptexenc1-20110705-1-mdv2011.0.x86_64 texlive-20110705-1-mdv2011.0.x86_64 perl-LaTeX-Driver-0.80.0-3-mdv2011.0.noarch [root@boulder]:(~)# cd /usr/bin [root@boulder]:(/usr/bin)# ln -s dvipdfmx dvipdf ghc-pandoc-types-1.16.1-1-mdv2011.0.x86_64 ghc-pandoc-types-devel-1.16.1-1-mdv2011.0.x86_64 ghc-pandoc-1.16.0.2-1-mdv2011.0.x86_64 pandoc-pdf-1.16.0.2-1-mdv2011.0.x86_64 pandoc-1.16.0.2-1-mdv2011.0.x86_64 pandoc-common-1.16.0.2-1-mdv2011.0.x86_64 ghc-pandoc-devel-1.16.0.2-1-mdv2011.0.x86_64 tex.stackexchange.com/questions ... including-a-jpg-image-source-code-compilation-in-pdflatex-doesnt-create-pdf I stumbled on the same error with pandoc when trying to convert epub to pdf : [macfarlane@boulder]:(~/Documents)$ pandoc -s -t latex --toc --chapters \ --latex-engine=lualatex $BOOK.epub -o $BOOK.pdf !LuaTeX error (file /tmp/tex2pdf.23440/3f21bef8dd2877aad72f5cddbf00284ca88fa0e7 .jpg): reading JPEG image failed (no marker found) ==> Fatal error occurred, no output PDF file produced! pandoc: Error producing PDF [macfarlane@boulder]:(~/Documents)$ Here's a workaround. Check to see if a tex file can be produced : [macfarlane@boulder]:(~/Documents)$ pandoc \ -s -t latex \ --toc --chapters \ --latex-engine=lualatex $BOOK.epub -o $BOOK.tex [macfarlane@boulder]:(~/Documents)$ Extract images and other media contained in the epub container to the path DIR, creating it if necessary, and adjust the images references in the [LaTeX] document so they point to the extracted files, with the option --extract-media= DIR . Select the current directory which also contains the ePub file. Add --extract-media=. which means extract in the current directory, which is also $HOME/Documents [macfarlane@boulder]:(~)$ cd Documents [macfarlane@boulder]:(~/Documents)$ pandoc \ -s -t latex \ --toc --chapters \ --latex-engine=lualatex \ --extract-media=. $BOOK.epub -o $BOOK.tex pandoc: extracting ./images/9781501144158.jpg pandoc: extracting ./images/com-01.jpg pandoc: extracting ./images/f0003-01.jpg pandoc: extracting ./images/f0005-01.jpg [ ----- extract-media logging shortened ---- ] pandoc: extracting ./images/f0177-01.jpg pandoc: extracting ./images/f0187-01.jpg pandoc: extracting ./images/logo.jpg pandoc: extracting ./images/logo1.jpg pandoc: extracting ./images/title.jpg [macfarlane@boulder]:(~/Documents)$ Repeal the extracted .jpg images by creating new LaTeX compatible JPEG images with the `convert' utility (from the imagemagick program suite) [macfarlane@boulder]:(~/Documents)$ cd images [macfarlane@boulder]:(~/Documents/images)$ convert logo1.jpg logo1.jpeg and Replace the previously with pandoc extracted .jpg images with the newly created .jpeg images : [macfarlane@boulder]:(~/Documents/images)$ mv logo1.jpeg logo1.jpg One can do this with a single for loop on the commandline : [macfarlane@boulder]:(~/Documents)$ [macfarlane@boulder]:(~/Documents)$ cd images/ [macfarlane@boulder]:(~/Documents/images)$ for i in *.jpg; do convert $i `echo $i | sed 's/jpg/jpeg/'`; done [macfarlane@boulder]:(~/Documents/images)$ rm -f *.jpg [macfarlane@boulder]:(~/Documents/images)$ for i in *.jpeg; do mv $i `echo $i | sed 's/jpeg/jpg/'`; done [macfarlane@boulder]:(~/Documents/images)$ cd .. [macfarlane@boulder]:(~/Documents)$ Run the first commandline again, but this time have the LuaTeX engine seek for its \includegraphics in the same directory as where the ePub images were extracted earlier ( --data-dir=DIRECTORY Specify the user data directory to search for pandoc data files. If this option is not specified, the default user data directory will be used. This is, in Unix: $HOME/.pandoc ) by adding the option --data-dir=. : [macfarlane@boulder]:(~/Documents)$ pandoc \ -s -t latex \ --toc --chapters \ --latex-engine=lualatex \ --data-dir=. $BOOK.epub -o $BOOK.pdf [macfarlane@boulder]:(~/Documents)$
[1] LaTeX: A Document Preparation System (2nd Edition)
[2] The LaTeX Companion (Tools and Techniques for Computer Typesetting) 2nd Edition
|
|