In response to closed ticket #850.
Having a problem with a header image on CentOS 5.9 running PHP 5.4.19 with GD and Imagick and the latest TCPDF installed. I can reproduce this problem on two boxes of the same specs. Works fine on my Mac.
The problem is when I try to run the PDF, the page takes forever to load then white screens.
[Fri Oct 18 15:46:33 2013] [error] [client 70.62.126.50] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /home/asentner/sabackoffice/vendor/tcpdf/tcpdf.php on line 7189
[Fri Oct 18 16:11:03 2013] [error] [client 70.62.126.50] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 130968 bytes) in /home/asentner/sabackoffice/vendor/tcpdf/tcpdf.php on line 7255
I upped the memory to 2048mb and the memory error went away. I changed the post time to 90 and it just generated more garbage in /tmp and still timedout.
I noticed that the one page load generates thousands of files prefixed mska_ and thousands more prefixed mskp in the /tmp directory which all appears to be my one image.
What are the mska and mskp temp files for? Is there an alternate way to use the image?
The library is unusable.
I can reproduce with example 003 (Custom header footer) using a custom header (see below) on any CentOS system running 5.9 with PHP 5.4 (Please see above for exact versions).
class BackofficeReportService extends TCPDF {
var $printedBy;
var $date;
// Custom constructor
public function __construct($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false, $pdfa=false) {
parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache, $pdfa);
$this->SetAuthor("BackOffice/".VERSION);
}
// Set Header Data
public function setPrintedBy($name) {
$this->printedBy = $name;
}
public function setDate($date) {
$this->date = $date;
}
//Page header
public function Header() {
$this->SetFont('helvetica', 'B', 20);
// Title
$this->Cell(0, 10, $this->title, 0, false, 'C', 0, '', 0, false, 'C', 'C');
$this->Ln();
$this->SetFont('helvetica', '', 10);
$this->Cell(0, 5, "Printed By: ".$this->printedBy, 0, false, 'C', 0, '', 0, false, 'C', 'T');
$this->Ln();
$this->SetFont('helvetica', '', 10);
$this->Cell(0, 5, "Date: ".$this->date, 0, false, 'C', 0, '', 0, false, 'C', 'T');
// Logo
$image_file = $_SERVER['BACKOFFICE_ROOT'].'/htdocs/assets/img/logo.png';
$this->Image($image_file, 15, 9, '40', '', 'PNG', '', 'T', false, 300, '', false, false, 0, false, false, false);
//$style = array('width' => 0.25, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0));
$this->Line(15, 23, 195, 23, array('width' => 0.25));
}
// Page footer
public function Footer() {
// Position at 15 mm from bottom
$this->SetY(-15);
// Set font
$this->SetFont('helvetica', 'I', 8);
// Page number
$this->Line(15, 282, 195, 282, array('width' => 0.25));
$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
Please don't close this ticket. I really like this library and would like to get this working. If you need something from me, let me know.
I can give you shell access if you need it as well.
After further review, I commented out the image and it did not resolve the problem. It seems it has nothing to do with the image but this issue with the tmp folder is alarming. Is it getting stuck in a loop somewhere?
Oh, and here is the code calling the class:
Last edit: Adam S 2013-10-19
If this issue has nothing to do with the images than this bug should be closed.
Please note that this is is not the place to ask for custom support.
If you think that TCPDF contains a bug, please provide a very simple example to reproduce it because I do not have time to debug custom code.
The examples (http://www.tcpdf.org/examples.php) do not work either (none of them). Please read the description. PHP is timing out. It has something to do with the library on a system with the specs provided (Enterprise Linux 5, very common among hosts). The library even using the examples provided on your site, cause PHP to time out. I find it odd that you think a pdf with an image (including example 003) creates thousands of temp files in the temp directory is not a bug but something that should be posted in the forum. This is a problem with TCPDF. Is this library no longer maintained? Is PHP 5.4 supported? If you are not interested in fixing this fatal issue, we'll find something else. I'd hate to do it, the library should do everything we need it to should we get this working. Now I ask, are you willing to help us out? I'll even give the project a donation if you willing to fix this issue to get us up and running. I really like this library. Thank you for putting the time you have this far.
Last edit: Adam S 2013-10-19
Unfortunately I am unable to reproduce your issue.
It can be a problem related to the imagick or gd libraries.
Would you please provide the exact verion of PHP, imagick and gd version you are using?
OK. This should be fixed in TCPDF 6.0.040.
Thank you for reporting this issue.
Please comment here if this solution doesn't work for you.
Unfortunately the latest did not. The tmp is now full of a ton of __tcpdf_imgmask_alpha_ and __tcpdf_imgmask_plain_ files and the page times out.
Here are the version numbers:
PHP 5.4.19 Running on Apache 2.2.3 as DSO
imagick Module version: 3.1.2
Image Magic Library Version: 6.2.8 05/07/12 (Stock shipped with OS)
GD: bundled (2.1.0 compatible)
libPNG: 1.2.10
Freetype: 2.2.1
Last edit: Adam S 2013-10-21
OK. This should be now fixed on TCPF 6.0.041.
Please try it and let me know if it works for you.
Great! The latest release fixes it. Thanks!