【问题标题】:Pandoc and html5 exporting pdf's with huge marginsPandoc 和 html5 以巨大的利润导出 pdf
【发布时间】:2017-09-04 16:12:48
【问题描述】:

所以我是第一次尝试 Pandoc。一切看起来都很棒,但是当通过 html5 (wkhtmltopdf) 导出时,我的 pdf 输出保存在各个方面都有很大的边距。

pandoc -t html5 -s example.md -o output.pdf

output.pdf(内容输出以红色突出显示)

我尝试过的:

  • 重新安装 pdflatex
  • 重新安装 wkhtmltopdf
  • 包含 CSS 以删除边距

我错过了什么吗?

我想要什么: 使用Typora 编写降价文档 -> 使用 Pandoc 应用 TOC 和页码 -> 使用 html5 导出具有自定义样式的 pdf。

【问题讨论】:

  • 如果您使用-t html,则不需要pdflatex。所以不要费心重新安装它。要更改样式,然后修改您的 HTML 模板:请参阅 pandoc.org/MANUAL.html#templates

标签: wkhtmltopdf pandoc


【解决方案1】:

这些通过变量为wkhtmltopdf 为我工作(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

(奇怪的是wkhtmltopdf 要求所有边距相同。)

【讨论】:

  • 这有效(在我的 Mac 上)但使用 -V margins=0.75in,例如,没有。我需要所有四个选项。
  • 我使用的是一个 css 文件(带有 pandoc 和 wkhtmltopdf),在我为所有边距设置 -V margin-top=0 等之前,css 边距没有任何效果。现在我可以用 CSS 来设置它们了。
【解决方案2】:

为了回答我自己的问题,这个问题是由 macOS 上的 wkhtmltopdf (0.12.4) 和据称是 Debian 引起的。我通过仅使用 wkhtmltopdf(没有 Pandoc)并尝试不同的参数(例如 --zoom--dpi--disable-smart-shrinking)来解决它。

见:

wkhtmltopdf generates tiny output on Mac

https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3241

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-16
    • 1970-01-01
    • 1970-01-01
    • 2022-12-03
    • 2016-08-29
    • 1970-01-01
    • 1970-01-01
    • 2014-02-08
    相关资源
    最近更新 更多