TCPDF - Header image only displays on first page

前端 未结 3 865
谎友^
谎友^ 2021-01-19 03:16

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

相关标签:
3条回答
  • 2021-01-19 03:57

    As said it is a tcpdf bug. In my case I had two logos in header one png and the other jpg. The problem happened only with the .png. Changing the image type from png to jpg solved the issue.

    0 讨论(0)
  • 2021-01-19 04:01

    I solved this by using base64 encoded string like this:

    $image = base64_encode(file_get_contents('path_to_image'));
    

    Then you can use it like this:

    <img src="@<?= $image ?>" />
    
    0 讨论(0)
  • 2021-01-19 04:18

    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);
    }
    
    0 讨论(0)
提交回复
热议问题