TCPDF在一个文档中为不同页面设置了不同的标题 [英] TCPDF set different headers for different pages in one document

查看:244
本文介绍了TCPDF在一个文档中为不同页面设置了不同的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在文档的第一页上使用不同的标题徽标,而在第二页上使用不同的标题徽标?

Is there a way to have a different header logo for the 1st page in a document and different for the 2nd page?

我认为在添加页面之间更改标头数据可能会达到目的,但是在我的测试中,添加第一页后设置标头似乎没有效果:

I thought that changing the header data between adding pages might do the trick, but in my tests it seems that setting the header after adding the first page has no effect:

/* other stuff
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->AliasNbPages();
*/

$pdf->SetHeaderData("logo_1.png", PDF_HEADER_LOGO_WIDTH, '', '');
$pdf->AddPage();
$pdf->writeHTML($htmlContent, true, 0, true, true);

$pdf->SetHeaderData("logo_2.png", PDF_HEADER_LOGO_WIDTH, '', '');
$pdf->AddPage();
$pdf->writeHTML($htmlContent2, true, 0, true, true);

上面的代码产生了一个包含2页的文档,每个页眉的标题都为logo_1.png.

The above produces a document with 2 pages, both having logo_1.png in header.

我需要自定义TCPDF吗?有人做过吗?我正在使用版本5.9.144.

Will I need to customize TCPDF itself? Has anyone done this? I'm using version 5.9.144.

推荐答案

奇怪.我遇到了同样的问题,但这在我的旧版本的TCPDF版本:4.8.009中有效,当我升级到5.9.149时,我注意到了这个问题.

Strange. I'm having the same issue, but this worked in my older version of TCPDF version:4.8.009 and I noticed the issue when I upgraded to 5.9.149.

我比较了2并将问题隔离到Header()函数.

I compared the 2 and isolated the issue to the Header() function.

我可以通过运行以下命令来强制它更改标题并接受它: $ pdf-> setHeaderTemplateAutoreset(true);

I could force it to allow me to change the header and accept it by running this: $pdf->setHeaderTemplateAutoreset(true);

这篇关于TCPDF在一个文档中为不同页面设置了不同的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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