donglan9517 2014-12-11 15:07
浏览 100

下载生成的PDF有多页内存问题

I am trying to generate bulk invoices (for printing) in the same PDF by using tcpdf library. The problem is that if there are too many (over 50 pages ) to generate the server will crash with this error.

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 72 bytes) in /home/user/public_html/lib/tcpdf/tcpdf.php on line 16680

So i can see that the max memory limit on my account is 335544320 bytes. I tried using ini_set('memory_limit', '-1'); but it cannot pass 335544320 bytes. On my localhost is working OK because i have all the memory_limit available.

So the question is how can fix this in order to work. To see or download the PDF containing all the invoices. I was thinking if this cannot be done because of the memory problem, to save each PDF in a folder and then zip and download the folder.

  • 写回答

1条回答 默认 最新

  • dqxz96998 2014-12-11 15:22
    关注

    TCPDF's contructor has $diskcache parameter:

    /**
     * @param $diskcache (boolean) If TRUE reduce the RAM memory usage by caching temporary data on filesystem (slower).
    */
    public function __construct($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false, $pdfa=false)
    

    Another option is to create individual pages/invoices as separate pdf files, and then merge them using any solution you have available. See Merge pdf files with php.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog