【问题标题】:Syntax for wkhtmltopdf page objectwkhtmltopdf 页面对象的语法
【发布时间】:2020-05-08 03:51:28
【问题描述】:
有人知道添加页面对象的语法吗?我从说明中尝试了以下内容,但这显然不是一个完整的示例。相同的命令减去“(页面)?”生成 PDF。我在运行 Catalina 10.15.2 的 Mac 上使用 wkhtmltopdf 版本 0.12.5。我的目标是将多个 HTML 页面组合成一个 PDF。 Google 和 SO 搜索都未能找到与我的问题相关的任何内容。
wkhtmltopdf (page)? pg01.html page1-3.pdf
-bash: syntax error near unexpected token `page'
【问题讨论】:
标签:
pdf-generation
wkhtmltopdf
html-to-pdf
【解决方案1】:
我的目标是将多个 HTML 页面合并为一个 PDF。
我认为 wkhtmltopdf 是可能的:
wkhtmltopdf pg01.html pg02.html pg03.html combined.pdf
如果您想要内部链接,则需要将所有页面合并到一个 html 中。
【解决方案2】:
我知道混乱来自哪里。
来自autogenerated documentation:
A page objects puts the content of a single webpage into the output document.
(page)? <input url/file name> [PAGE OPTION]...
Options for the page object can be placed in the global options and the page
options areas. The applicable options can be found in the Page Options and
Headers And Footer Options sections.
我认为这只是说该页面可以是可选的,并且可以引用主文档或封面或标题文档。
在我看来,您想要一个由不同 HTML 文档组成的 PDF。我不相信单独使用 wkhtmltopdf 是不可能的,但是,您可以将多个 HTML 文档或网站单独转换为 PDF,然后在完成后将它们与 PDFtk server 之类的东西结合起来。
看起来像这样:
wkhtmltopdf doc1.html doc1.pdf && \
wkhtmltopdf doc2.html doc2.pdf && \
wkhtmltopdf doc3.html doc3.pdf && \
pdftk doc1.pdf doc2.pdf doc3.pdf cat output final.pdf