Html2Pdf中的分页符 [英] Page break in Html2Pdf

查看:621
本文介绍了Html2Pdf中的分页符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在生成一个动态pdf文件,该文件包含大约10,000个用户的数据,通常该应用程序是使用MySQL和PHP开发的.动态内容是如此繁重,以至于我发现很难使用fpdf()类进行处理.因此,我使用ob_get_clean()将输出的PHP页面转换为HTML文件.现在,已成功生成html文件和pdf文件.但是我想在每个用户的数据之后留下一个分页符,也就是说,每个用户的数据都必须从一个新的页面开始.我无法使用任何HTML标记,因为在动态生成的HTML文件中,所有内容都不在<html></html>标记之内.请帮助我,以便我在每个用户的数据之后如何在pdf文件中进行分页...预先感谢:)

I am in the process of generating a dynamic pdf file, which contains data of around 10,000 users, in general the app is developed using MySQL and PHP. The dynamic content is so heavy that, I found it difficult to process with fpdf() class. So I converted my output PHP page as a HTML file using ob_get_clean(). Now the html file is generated successfully and also the pdf file. But i want to leave a page break after each user's data, that is every user's data must start in a fresh page. I couldn't use any HTML tags because, in the dynamically generated HTML file, everything is out of the <html> and </html> tags. Please help me so that some how i make a page break in the pdf file after every user's data... Thanks in advance :)

推荐答案

我在遇到相同问题后才想到了这一点.他们使用DOES的解析器支持page-break-after标记,但是html2pdf不起作用.

i just figured this out after having the same problem. the parser that they use DOES support the page-break-after tag, but the html2pdf does not work.

我认为我可以通过对html2pdf.class进行以下修改来使它起作用:

i think i have it working by doing the following modifications to html2pdf.class:

第4174行周围,里面的第一件事:

around line 4174, the first thing inside:

protected function _tag_close_P($param){

应为:

   if($this->parsingCss->value['page-break-after'] == "always")
        $this->_setNewPage();

第2961行附近,里面的第一件事:

around line 2961, the first thing inside:

protected function _tag_close_DIV($param, $other='div'){

应为:

 if($this->parsingCss->value['page-break-after'] == "always")
        $this->_setNewPage();

这篇关于Html2Pdf中的分页符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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