我正在使用TCPDF生成2页的pdf文档。
我在文档中添加了页眉和页脚。页眉和页脚的文本部分正确显示在每一页上,但是当我在页眉中包含图像徽标时,它仅显示在第一页上。
public function Header()
{
$this->Image('/home/xxxxxx/public_html/xxxxxxxx/uploads/logo/logo.png',10,6,0,13);
$this->SetFont('helvetica','B',20);
$this->Cell(80);
$this->Cell(0,0, $project->name . ' - Project Plan',$frame,0,'R');
$this->Ln(8);
$this->SetFont('helvetica','',10);
$this->Cell(0,0, $organisation->name,$frame,0,'R');
$this->Ln(10);
}
有人知道我在做什么错吗?
谢谢
最佳答案
我认为与页眉/页脚无关,但我认为TCPDF有一个错误,即多次加载相同图像文件的图像功能已损坏,如此处报告的TCPDF - image displayed only once
实际版本tecnickcom / tcpdf:6.2.26上也存在该错误
我通过将图像加载到外部并将其作为字符串传递给函数来解决此问题。
public function Header()
{
$this->Image('@'.file_get_contents('/home/xxxxxx/public_html/xxxxxxxx/uploads/logo/logo.png'),10,6,0,13);
$this->SetFont('helvetica','B',20);
$this->Cell(80);
$this->Cell(0,0, $project->name . ' - Project Plan',$frame,0,'R');
$this->Ln(8);
$this->SetFont('helvetica','',10);
$this->Cell(0,0, $organisation->name,$frame,0,'R');
$this->Ln(10);
}