wkhtmltopdf - 将内容添加到最后一页的底部 [英] wkhtmltopdf - Add content to the bottom of the last page
问题描述
我使用wkhtmltopdf从HTML创建PDF报表,我需要创建一个遵循此模式的自定义报表:
I am using wkhtmltopdf to create PDF reports from HTML, I need to create a custom report that follows this pattern:
- 一个可以有1到n行的表格(应该使用任意数量的页面)
将所有这些组合在一起就是窍门;然而,因为步骤3的信息立即出现在表之后,是否有一种方法将内容放在页面的末尾?
Putting all this together does the trick; however because step 3 info appears immediately after the table, is there a way to put the content at the end of the page?
我甚至不确定这个解决方案是否基于CSS或wkhtmltopdf。
I am not even sure if this solution is CSS based or wkhtmltopdf based.
推荐答案
http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf-0.9.9-doc.html
查看页脚和标题部分。
您可以使用 - footer-html
与一些JavaScript结合使用。
You can use --footer-html
combined with some JavaScript to do this.
wkhtmltopdf --footer-html footer.html http://www.stackoverflow.com/ so.pdf
我基于我的 footer.html
上面链接中提供的示例:
I based the contents of my footer.html
on the example provided in the link above:
<!DOCTYPE html>
<script>
window.onload = function() {
var vars = {};
var x = document.location.search.substring(1).split('&');
for (var i in x) {
var z = x[i].split('=', 2);
vars[z[0]] = unescape(z[1]);
}
//if current page number == last page number
if (vars['page'] == vars['topage']) {
document.querySelectorAll('.extra')[0].textContent = 'extra text here';
}
};
</script>
<style>
.extra {
color: red;
}
</style>
<div class="extra"></div>
这篇关于wkhtmltopdf - 将内容添加到最后一页的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!