Dec 8, 2012 at 3:43 PM
Edited Dec 8, 2012 at 3:44 PM
Im using PHPExcel v1.7.8; PHP v5.3.13 on a Windows7 maxchine with WAMP.
What I would like to do is generate a pdf from a worksheet for download. Below is the code I'm using.
$rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF;
$rendererLibrary = 'tcPDF5.9';
$rendererLibraryPath = PHPWS_SOURCE_DIR . 'mod/planning/Classes/tcpdf/';
if (!PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath))
'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
'at the top of this script as appropriate for your directory structure'
$inputFileName = PHPWS_SOURCE_DIR . [PathToMyFile]';
$sheetname = "myWorksheet";
$reader = new PHPExcel_Reader_Excel2007;
$phpExcel = $reader->load($inputFileName);
// Redirect output to a client’s web browser (PDF)
$objWriter = PHPExcel_IOFactory::createWriter($phpExcel, 'PDF');
Code executes without errors. But it just doesn't generate a pdf.
In the end I get an error that the memory is exhausted or that the maximum execution time has expired (which I extended to some 5 minutes).
The Excel file is just one worksheet with a little bit of text in it.
So what can I do aboput this? I read more of these issues on the forum but couldn't find a solution.
Hope to hear from you.
Dec 9, 2012 at 12:02 PM
Edited Dec 9, 2012 at 12:03 PM
The PDF Writers are generally slow, though you will find different speeds and memory demands if you use different rendering libraries (e.g. mPDF, DomPDF). I test against a number of libraries at different versions, including tcPDF 5.9.
We can't really control how efficiently 3rd party libraries run, but you could always try generating HTML instead, then running that through an external CLI PDF renderer to see if that is faster.