I'm using TCPDF (the latest version – 6.0.023) to generate PDFs. In the document's header I show a logo (either in JPEG or PNG format). It turns out that when using 'large' images (> 30KB), TCPDF generates a corrupt PDF file.
This is the code that displays the image:
<?php
public function Header() {
// $this->headerLeftLogo = '@' . $image;
// $this->logoHeight = 8;
$type = (...some check...) ? 'JPEG' : 'PNG';
$this->Image($this->headerLeftLogo, $this->getX(), $this->getY(), 0, $this->logoHeight, $type);
}
?>
After inspecting the source code of the generated PDF, and comparing a good and corrupt PDF, it seems like the corrupt PDF files just end somewhere in the middle of the document. Some (readable) information I see at the end of a good PDF is not present in the corrupt PDF.
No errors show up while generating the PDF. (All PHP errors are turned on.)
When running TCPDF's example 9 (in which a large image is displayed), no problems occur.