如何在header中绑定动态值以及如何隐藏特定页面的header?

How to bind dynamic values in the header and how to hide header for the specific pages?

我正在使用 wkhtmltopdf (0.12.6)。我无法实现以下两件事。

当我使用 wkhtmltopdf 时,我只能注入一个 header html。我不知道如何进行多页 header 或如何更改 header 值。

在 wkhtmltopdf 中,页面 header/footer 呈现为单独的 HTML 文档。这意味着他们无法直接访问 'current page' 内容;但是,特殊的 'tokens' - 如当前页码、总页数、当前 'section' - 作为查询参数传递,它们可以在 header/footer HTML 模板中使用 JS 访问。

查看此 wkhtmltopdf 帮助(“页脚和页眉”部分):https://wkhtmltopdf.org/usage/wkhtmltopdf.txt

您可以粘贴类似的块并根据页码自定义(甚至隐藏)页眉内容(或当前 'section' - 在 wkhtmltopdf 中这对应于 'last' // 标签的值) .请注意,您可以隐藏内容,但是 header/footer 的 height(在页面上分配 space)在所有页面上都是相同的,因为 wkhtmltopdf 会计算必要的边距只有一次(对于带有页眉的第一页),然后对所有下一页使用相同的值。