phpspreadsheet 为大文件生成 PDF 格式的 CSS 输出

phpspreadsheet generating css output on pdf for large files

提问人:Vianick Oliveri 提问时间:10/25/2023 更新时间:11/3/2023 访问量:33

问:

我有一份用phpspreadsheet生成的销售报告。一切正常,我可以毫无问题地导出为 XLSX 和 PDF,除了当文件变得太大(大约 24 页)时,PDF 导出会显示 PDF 中的所有 CSS,并且文件没有应用 css 规则。在 PDF 中显示所有 CSS 后,正常报告将继续(没有 CSS 规则)。XLSX 导出工作正常。

这是 PDF 文件开头的样子:

Office 2007 XLSX 销售报表 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 }......等等

没有错误输出或“无法打开此文件”或什么都没有,是具有该输出的工作 PDF 文件。

我的代码是:

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');
}
CSS PDF mpdf phpspreadsheet

评论


答: 暂无答案