我已经下载了https://hea-www.harvard.edu/~fine/Tech/vi.html文件使用wget -p -k https://hea-www.harvard.edu/~fine/Tech/vi.html
然后运行pandoc --latex-engine=xelatex -o vi.pdf vi.html
此生成 -
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}}
当我使用pdflatex
(pandoc 中的默认 latex 引擎)使用pandoc -o vi.pdf vi.html
此产品时 -
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}}
我也用wkhtmltopdf https://hea-www.harvard.edu/~fine/Tech/vi.html
weblink 制作 pdf。但是,在wkhtmltopdf
解决方案中我无法控制背景颜色。我想制作黑白 pdf。
答案1
拿赫伯特密码并将其放入文件中:
% 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}
现在您可以使用以下选项调用 pandoc:--pdf-engine-opt=-shell-escape --include-in-header=gif2png.tex
例子:
以这个简单的 html 文件为例:
<!-- file: test.html -->
<p>Here is a gif:</p>
<img src="test.gif" title="A dummy picture" alt="The gif" />
还有一个 gif 动图test.gif
:
并运行 pandoc:
pandoc test.html --pdf-engine-opt=-shell-escape --include-in-header=gif2png.tex -o test.pdf
您将获得以下 pdf 文件:
警告:
epstopdf
仅支持pdflatex
pdf lualatex
-engine