Html2Pdf中的分页符

Gre*_*orn 4 php mysql page-break html2pdf

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

小智 13

html2pdf支持页面标记:

protected function _tag_open_PAGE($param) {} 
Run Code Online (Sandbox Code Playgroud)

在第2229行.您可以看到支持哪些属性.例如,以下创建一个横向页面和一个纵向模式页面:

<page orientation="l">
... some content ...
</page>
<page orientation="p">
... some content ...
</page>
Run Code Online (Sandbox Code Playgroud)


Tha*_*ung 10

基于macdabby的工作(不起作用).但多亏了他,这个想法是正确的.

Html2Pdf v4.03

例如,我们想要解析标签DIV:

html2pdf.class.php第2948行:

protected function _tag_close_DIV($param, $other='div')
{
    if ($this->parsingCss->value['page-break-after'] == "always")
      $this->_setNewPage(null, '', null, $this->_defaultTop);
      $this->parsingCss->setPosition();
    ...
}
Run Code Online (Sandbox Code Playgroud)

parsingCss.class.php第114行:

//add a new style declaration
public function initStyle()
{
    ...
    $this->value['page-break-after'] = null;
}
Run Code Online (Sandbox Code Playgroud)

第1024行为switch case添加一个新的处理程序:

case 'page-break-after':
    $this->value[$nom] = $val;
    break;
Run Code Online (Sandbox Code Playgroud)

然后为了它的工作,你的html内容应该包含break元素

 <div style="page-break-after:always; clear:both"></div>
Run Code Online (Sandbox Code Playgroud)

注意区分大小写的风格,不确定插件是否处理它


mac*_*bby 2

我在遇到同样的问题后才发现这一点。他们使用的解析器确实支持 page-break-after 标签,但 html2pdf 不起作用。

我想我可以通过对 html2pdf.class 进行以下修改来使其工作:

大约第 4174 行,里面的第一件事是:

protected function _tag_close_P($param){
Run Code Online (Sandbox Code Playgroud)

应该:

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

大约第 2961 行,里面的第一件事是:

protected function _tag_close_DIV($param, $other='div'){
Run Code Online (Sandbox Code Playgroud)

应该:

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