dese php,PHP - Manual: PDF_add_textflow (官方文档)

If you get an error like this:

PHP Fatal error:  Allowed memory size of 16777216 bytes exhausted (tried to allocate 3072 bytes) in /var/www/html/pdf/starter_textflow.php on line 70

It is because you are sending too much data to the "add_textflow" function.  Increasing the memory in the php.ini file won't fix the problem.  The solution is to try buffering the data you send to the function.

For example, if this fails:

$text="Lorem ipsum dolor sit amet, consectetur adi­pi­sicing elit, sed do eius­mod tempor incidi­dunt ut labore et dolore magna ali­qua. Ut enim ad minim ve­niam, quis nostrud exer­citation ull­amco la­bo­ris nisi ut ali­quip ex ea commodo con­sequat. Duis aute irure dolor in repre­henderit in voluptate velit esse cillum dolore eu fugiat nulla pari­atur. Excep­teur sint occae­cat cupi­datat non proident, sunt in culpa qui officia dese­runt mollit anim id est laborum. ";//send lots of data all at once$max=100;

for($i=0;$iadd_textflow($tf,$text,$optlist1);?>

Try something like this instead:

$text="Lorem ipsum dolor sit amet, consectetur adi­pi­sicing elit, sed do eius­mod tempor incidi­dunt ut labore et dolore magna ali­qua. Ut enim ad minim ve­niam, quis nostrud exer­citation ull­amco la­bo­ris nisi ut ali­quip ex ea commodo con­sequat. Duis aute irure dolor in repre­henderit in voluptate velit esse cillum dolore eu fugiat nulla pari­atur. Excep­teur sint occae­cat cupi­datat non proident, sunt in culpa qui officia dese­runt mollit anim id est laborum. ";//send chunks of data$max=100;

for($i=0;$iadd_textflow($tf,$text,$optlist1);?>

In the second example we send less data, but we call the function more often.  With the first example, I could only generate 3 or 4 pages of a PDF; with the latter example I could generate 200+ page PDF's.

This took me a while to debug; hope it saves someone else some time. :)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值