wkhtmltopdf - 将内容添加到最后一页的底部 [英] wkhtmltopdf - Add content to the bottom of the last page

查看:186
本文介绍了wkhtmltopdf - 将内容添加到最后一页的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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. 一个可以有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屋!

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