TCPDF - Header image only displays on first page

心已入冬 提交于 2019-12-11 00:14:37

问题


I am using TCPDF to generate a 2 page pdf document.

I have added a header and a footer to the document. The text part of the header and footer shows up correctly on each page however when I include an image logo in the header it is only showing up on the first page.

   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);
}

Does anyone have any idea what I am doing wrong here?

Thanks


回答1:


I think is not related to header/footer, but I think TCPDF has bug that broken Image function with same image file loaded multiple times as reported here TCPDF - image displayed only once

bug also present on actual version tecnickcom/tcpdf:6.2.26

I resolve this problem by loading image outside and pass to the function as string.

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);
}


来源:https://stackoverflow.com/questions/52662271/tcpdf-header-image-only-displays-on-first-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!