I can read an xlsx file using PHPSpreadsheet just fine. The problem is that when I try to write it out to PDF the result is blank when I bring it up in Acrobat, even though the PDF file is about 840K.
I have tried Mpdf and Dompdf but they either take too long and time out, or run out of memory.
The .xlsx file is only 161K.
Here is the gist of my code:
$full_file_path = "/full/path/to/my/file.xlsx";
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile($full_file_path);
$excelSpreadsheet = $reader->load($full_file_path);
$PDFWriter = new \PhpOffice\PhpSpreadsheet\Writer\Pdf\Tcpdf($excelSpreadsheet);
$PDFWriter->writeAllSheets();
$PDFWriter->save("blarg.pdf");
When I run this code blarg.pdf gets updated and has a size of around 843K. But, when I open it in Acrobat it shows up as blank.
No errors appear in the logs.
In a separate test I was able to write out the Excel file as (ugly) HTML just fine.
Any idea what I'm doing wrong?
Random facts:
- Excel file has multiple sheets.
- Excel file created by Excel for Mac version 15.28
- Mac OSX Sierra 10.12.6
- PHP 5.6.28
- phpoffice/phpspreadsheet : 1.1.0
- tecnick.com/tcpdf : 6.2.13