我的wkhtmltopdf. 我需要从 生成文档HTML,其中包含第一页顶部的页眉和最后一页底部的页脚。
在我看来,最好的解决方案是将我HTML的文件分成3 个单独的文件:"header.html","content.html"和"footer.html". 这是可能的wkhtmltopdf。我设法footer使用此解决方案仅在第一页和最后一页上设置此页眉:
wicked_pdf:是否可以仅在第一页上显示页眉而页脚只在最后一页上显示?
问题是我的页眉和页脚很大(5 厘米高)。这就是为什么我需要储备margin-top和margin-bottom在wkhtmltopdf中,利润率与此值有我的页眉和页脚“安装”。这使得我有5厘米margin-top和margin-bottom我的文档的每一页上。
我使用wkhtmltopdf命令:
wkhtmltopdf --header-html 'my header html' --footer-html 'my footer html' --margin-right '0' --margin-left '0' --margin-top '50' --margin-bottom '50' --print-media-type 'my content html' test.pdf
Run Code Online (Sandbox Code Playgroud)
要仅在第一页上设置标题,我有这个JavaScript:
function headerCheck() {
var x=document.location.search.substring(1).split('&');
for (var i in x) {
if(x[i] == "page=1")
document.getElementsByClassName("headerContent")[0].style.display = "block"; …Run Code Online (Sandbox Code Playgroud)