Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TCPDF - Header image only displays on first page

Tags:

tcpdf

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

like image 742
Simon Harvey Avatar asked Oct 05 '18 09:10

Simon Harvey


1 Answers

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);
}
like image 75
Luca Camillo Avatar answered Sep 26 '22 13:09

Luca Camillo