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 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换