1

I have downloaded https://hea-www.harvard.edu/~fine/Tech/vi.html file using wget -p -k https://hea-www.harvard.edu/~fine/Tech/vi.html then run pandoc --latex-engine=xelatex -o vi.pdf vi.html this produce -

pandoc: Error producing PDF from TeX source.
! LaTeX Error: Cannot determine size of graphic in ../images/vi.gif (no Boundin
gBox).

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.884 ...html}{\includegraphics{../images/vi.gif}}

And when I use pdflatex(default latex-engine in pandoc) by using pandoc -o vi.pdf vi.html this produce -

pandoc: Error producing PDF from TeX source.
! LaTeX Error: Unknown graphics extension: .gif.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.884 ...html}{\includegraphics{../images/vi.gif}}

I also use wkhtmltopdf https://hea-www.harvard.edu/~fine/Tech/vi.html to make pdf from weblink. But, in wkhtmltopdf solution I have no control over the background color. I want to make a black and white pdf.

DG'
  • 21,727
alhelal
  • 2,451

1 Answers1

2

Take Herbert's code and put it in a file:

% file: gif2png.tex
% Herbert's code:
% https://tex.stackexchange.com/questions/7602/how-to-add-a-gif-file-to-my-latex-file/7608#7608

\usepackage{epstopdf}

\epstopdfDeclareGraphicsRule{.gif}{png}{.png}{convert gif:#1 png:\OutputFile}
\AppendGraphicsExtensions{.gif}

Now you can call pandoc with the options: --pdf-engine-opt=-shell-escape --include-in-header=gif2png.tex

Example:

Take this simple html file:

<!-- file: test.html -->
<p>Here is a gif:</p>
<img src="test.gif" title="A dummy picture" alt="The gif" />

And a gif called test.gif:

enter image description here

And run pandoc:

pandoc test.html --pdf-engine-opt=-shell-escape --include-in-header=gif2png.tex -o test.pdf

You will get this pdf as a result:

enter image description here


Caveat:

epstopdf supports only pdflatex and lualatex as pdf-engine

DG'
  • 21,727