[英]Create PDF file with BIG html CODE
I have to generate PDF document from big HTML code (created 1000 or more pages). 我必须从大型HTML代码(创建1000或更多页面)生成PDF文档。 But standard method limited me - memory.
但是标准方法限制了我-内存。 Standard method:
标准方法:
$html = generatePDF($data_to_pdf);
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper('a4', 'landscape');
$dompdf->render();
$pdf = $dompdf->output();
file_put_contents('pdf/' . $tmp_name . '.pdf', $pdf);
The memory is too small so I need to save the data in part. 内存太小,因此我需要部分保存数据。 How to generate PDF page by page?
如何逐页生成PDF? Or something like that?
或类似的东西? How to fix memory problem?
如何解决内存问题?
Try taking a look at this: https://pdfmerger.codeplex.com/ 尝试看看这个: https : //pdfmerger.codeplex.com/
Then, divide the html, render each part into a separate file, and then merge them afterwards.. 然后,将html分割,将每个部分渲染到一个单独的文件中,然后再合并它们。
This should work for you in this case. 在这种情况下,这应该对您有用。
ini_set("memory_limit", 64MB);
$html = generatePDF($data_to_pdf);
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper('a4', 'landscape');
$dompdf->render();
$pdf = $dompdf->output();
file_put_contents('pdf/' . $tmp_name . '.pdf', $pdf);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.