Note that there are some explanatory texts on larger screens.

plurals
  1. POPHPExcel returns empty PDF file
    text
    copied!<p>I have a project based on PHPExcel and I want to have two output types: .xls and .pdf. The .xls output is working great, no problem with that, but as soon as I want to output the result as a .pdf file, it's not working... the final .pdf file is a 0B file, so total empty.</p> <p>Here is the PDF writer (tcPDF, located in the /var/www/tcpdf directory) inicializaion part at the beginning of the file:</p> <pre><code>/** Include PHPExcel */ require_once 'scripts/PHPExcel.php'; /** Include path **/ set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/'); /** PHPExcel_IOFactory */ include 'scripts/PHPExcel/IOFactory.php'; $objPHPExcel = new PHPExcel(); $rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF; $rendererLibrary = 'tcpdf'; $rendererLibraryPath = $rendererLibrary; if (!PHPExcel_Settings::setPdfRenderer( $rendererName, $rendererLibraryPath )) { die( 'Please set the $rendererName and $rendererLibraryPath values' . PHP_EOL . ' as appropriate for your directory structure' ); } </code></pre> <p>Here comes the manipulation functions, so skip these... </p> <p>This is the output section:</p> <pre><code>$objPHPExcel-&gt;setActiveSheetIndex(0); if($_GET['format'] == 'xls'){ header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="bs-export.xls"'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter-&gt;save('php://output'); exit; } if($_GET['format'] == 'pdf'){ header('Content-Type: application/pdf'); header('Content-Disposition: attachment;filename="bs-export.pdf"'); $objWriter = new PHPExcel_Writer_PDF($objPHPExcel); $objWriter = PHPExcel_IOFactory::createWriter($objPHPexcel, 'PDF'); $objWriter-&gt;setSheetIndex(0); $objWriter-&gt;save('php://output'); exit; } </code></pre> <p>Can someone help me out here what could be the problem?</p> <p>Thank you very much!!</p> <p><strong>EDIT:</strong> I didn't notice it had some variable name errors... so I corrected the </p> <pre><code>$objWriter = PHPExcel_IOFactory::createWriter($objPHPexcel, 'PDF'); </code></pre> <p>line to :</p> <pre><code>$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF'); </code></pre> <p>After this the PDF file isn't 0B site anymore, but its't still a blank page... The XLS output is okay.</p> <p><strong>EDIT2:</strong> Very strange... This returns a total blank page too:</p> <pre><code>$objWriter = new PHPExcel_Writer_HTML($objPHPExcel); $objWriter-&gt;save("pdf-test.htm"); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload