如何在 wkhtmltopdf 中使用页脚和页眉? [英] How can I use footers and headers with wkhtmltopdf?

查看:135
本文介绍了如何在 wkhtmltopdf 中使用页脚和页眉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一种情况,我不得不在生成的 PDF 打印输出中使用页脚和页眉.CSS 解决方案仅适用于第一页.我发现的唯一信息是 WKPDF 根本不支持它,但这可以追溯到 2009 年,所以可能会发生一些变化.

I encountered a situation where I had to use footers and headers in my generated PDF printounts. CSS solution works for the first page only. And the only information I found is that it is not supported in WKPDF at all, but this dates back to 2009, so something might have changed.

有人成功过吗?

谢谢.

推荐答案

Wkhtmltopdf 甚至支持非常复杂的页眉和页脚.

Wkhtmltopdf does support even very complex headers and footers.

wkhtmltopdf.exe -T 50mm --header-html www.google.com www.stackoverflow.com test.pdf && test.pdf

该命令将 www.google.com 上的页面用作 www.stackoverflow.com 的每个页面的 50 毫米标题.

That command uses the page at www.google.com as a 50mm header for www.stackoverflow.com for every page.

注意:如果您使用自定义页面作为页眉/页脚,则需要在页眉/页脚 HTML 的开头添加

Note: If you use a custom page for the header/footer, you need to add <!DOCTYPE HTML> in the beginning of your header/footer HTML!

这篇关于如何在 wkhtmltopdf 中使用页脚和页眉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆