phpspreadsheet generating css output on pdf for large files

82 Views Asked by At

I have a sales report generated with phpspreadsheet. Everything is working fine, I can export as XLSX and PDF with no problem, except that when the file gets too large (around 24 pages), the PDF export is showing all the CSS in the PDF and the file has no css rules applied. After all CSS shows in the PDF, the normal report continues (with no CSS rules). XLSX export is working fine.

This is how the beggining of the PDF file looks like:

Office 2007 XLSX Sales Report html { font-family:Calibri, Arial, Helvetica, sans-serif; font-size:11pt; background-color:white } a.comment-indicator:hover + div.comment { background:#ffd; position:absolute; display:block; border:1px solid black; padding:0.5em }......and so on

There is no error output or "Cannot open this file" or nothing, is a working PDF file with that output.

My code is:

if(isset($_GET['pdf']) && $_GET['pdf'])
{
    header("Content-type:application/pdf");
    header('Content-Disposition: attachment; filename="sales-report.pdf"');
    header('Cache-Control: max-age=0');
    $objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($objPHPExcel, 'Mpdf');
    $objWriter->save('php://output');
}
0

There are 0 best solutions below