Pandoc and html5 exporting pdf's with huge margins

大城市里の小女人 提交于 2020-08-09 18:44:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!