问题
So I'm trying Pandoc for the first time. Everything seems great but when exporting via html5 (wkhtmltopdf) my pdf output is saved with huge margins on all sides.
pandoc -t html5 -s example.md -o output.pdf
output.pdf (content output highlighted in red)
What I've tried:
- Reinstalling pdflatex
- Reinstalling wkhtmltopdf
- Including CSS to remove the margins
Am I missing something?
What I want: Write a markdown document using Typora -> Use Pandoc to apply TOC and page numbering -> Use html5 to export pdf with custom styling.
回答1:
These pass through vars for wkhtmltopdf
worked for me (ubuntu 18.10 pandoc 2.6) : https://pandoc.org/MANUAL.html#variables-for-wkhtmltopdf
pandoc -t html5 -V margin-top=3 -V margin-left=3 -V margin-right=3 -V margin-bottom=3 -V papersize=letter -s example.md -o output.pdf
(Oddly wkhtmltopdf
required all margins be the same.)
回答2:
To answer my own question, the issue is caused by wkhtmltopdf (0.12.4) on macOS and supposedly Debian. I solved it by using only wkhtmltopdf (without Pandoc) and trying different parameters such as --zoom
--dpi
and --disable-smart-shrinking
.
See:
wkhtmltopdf generates tiny output on Mac
https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3241
来源:https://stackoverflow.com/questions/46040862/pandoc-and-html5-exporting-pdfs-with-huge-margins