Reputation: 1400
I'm trying to generate a multiple page pdf with TCPDF version 6.0.010. The script you see below worked perfectly when I was using version 5.9.009.
Every page has a logo in it. The pdf generated by TCPDF version 6.0.010 shows only once (on 1st page) this logo. When I load different images on these pages, the images are displayed correctly(as long as there are no duplicates).
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, 10, 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->SetFont('freesans', '', 18);
foreach ($items as $item) {
$pdf->AddPage();
$html = myHtmlTemplate($item);
$pdf->writeHTML($html, true, false, true, false, '');
}
$file = $pdf->Output('myPDF.file', 'S');
Upvotes: 0
Views: 2629
Reputation: 1
Or get the latest version of TCPDF... I had the same problem and upgraded to 6.0.093 and now it works...
Upvotes: -1
Reputation: 11
I have the same problem my work around is to load the image as a base64 image string and use that instead.
example:
$img= "myimage.jpg";
$imgdata = 'data: '.mime_content_type($img).';base64,'. base64_encode(file_get_contents($img));
$html = "<img src=\"$imgdata\"/>";
This should help, its not a fix and it is a bit slower, but it works for me. I Trust this helps.
Upvotes: 1