【问题标题】:sethtmlheader mpdf not workingsethtmlheader mpdf 不工作
【发布时间】:2013-07-18 16:04:08
【问题描述】:

sethtmlheader mpdf 不工作

我有几个 html 页面,我有存在、封面、左边的图像

每个都有 html :

<!DOCTYPE HTML>

问题在于它没有在 pdf 上打印页眉或页脚

$this->load->library('pdf');


$pdf = $this->pdf->load();



$pdf->debug = true;


$pdf->WriteHTML($html);


$pdf->SetHTMLHeader('<div style="text-align: right; font-weight: bold;">My document</div>',true);



$pdf->WriteHTML($htmlpresences);                     

$pdf->SetHTMLFooter('
    <table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;"><tr>
    <td width="33%"><span style="font-weight: bold; font-style: italic;">{DATE j-m-Y}</span></td>
    <td width="33%" align="center" style="font-weight: bold; font-style: italic;">{PAGENO}/{nbpg}</td>
    <td width="33%" style="text-align: right; ">My document</td>
    </tr></table>
    ');

【问题讨论】:

    标签: php codeigniter mpdf


    【解决方案1】:

    首先,您应该在调用 WriteHTML 之前设置页眉和页脚 - 在您的代码中,您在告诉 mpdf 使用什么页眉之前已经编写了页面的内容。

    此外,根据您使用的 mpdf 版本,SetHTMLHeader 的第二个参数应该是一个“页面”值,指示在何处使用标题(奇数页、偶数页、全部或无) - 请参阅此处的文档:http://mpdf1.com/manual/index.php?tid=152。因此,您需要删除您使用过的 'true' 参数,因为这不是必需的。

    实际上,通过使用带有参数的标签,我在 html 本身而不是代码中设置页眉和页脚更成功。您也可以尝试将标头 html 包装在标签中,看看是否有帮助。

    【讨论】:

    【解决方案2】:

    首先,您应该在调用 WriteHTML 之前设置页眉和页脚 - 在您的代码中,您在告诉 mpdf 使用什么页眉之前已经编写了页面的内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 2021-12-07
      • 2019-01-27
      • 1970-01-01
      相关资源
      最近更新 更多