Dompdf failing on large renders.

10,712 views
Skip to first unread message

init.d.httpd

unread,
Oct 14, 2009, 10:05:26 AM10/14/09
to dompdf
Fatal error: Maximum execution time of 300 seconds exceeded in /var/
www/vhosts/*****/**/***/dompdf/include/frame.cls.php on line 676

Any ideas?

Paul Waring

unread,
Oct 14, 2009, 11:17:30 AM10/14/09
to dom...@googlegroups.com

What is contained in the PDF you are trying to generate? It could be
that you are trying to generate a large PDF which can't be completed in
under 300 seconds - though that seems unlikely (the memory limit is
usually exceeded first in my experience).

The other possibility is that your script is waiting a long time on
other code (e.g. fetching results from a database) and by the time
dompdf is called it has exceeded the maximum execution time.

Paul

--
Paul Waring
http://www.pwaring.com

init.d.httpd

unread,
Oct 22, 2009, 2:42:23 PM10/22/09
to dompdf
I thought I replied to this a while ago, But I guess I clicked the
wrong button.

This script has been in place for quite some time, and it still works
for every other user of this system. This specific user is having an
issue. I'm trying to nail down what exactly is causing the hang up
right now.

I've taken out all the script calls, and basically have four lines. It
gets the end html file, and then DOMpdf takes it from there. The HTML
file is only 67Kb in size. I'm slowly taking pieces of it out to see
if I can figure out the issue.

P.S Kudos to you guys for picking this project up. There is a big need
for an open source server side PDF rending application ( that works
well ).

Thanks.

init.d.httpd

unread,
Oct 23, 2009, 2:04:20 PM10/23/09
to dompdf
Well it turns out, this user decided to write a book inside of a text
area. the textarea spanned more than one page of the PDF and dompdf
crashes. I figured this out through hours of trial and error with this
particular PDF render.

Heather V.

unread,
Oct 23, 2009, 10:51:56 PM10/23/09
to dom...@googlegroups.com
Interesting you say that because I'm still having problems.

"Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 77255405 bytes) in C:\... on line 135"

I have this:
$old_limit = ini_set("memory_limit", "128M");
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("roster.pdf");

I've changed to memory limit, I've changed the memory in my php.ini and still don't understand why I continue to get the above message. Mind you, the error message does change after I change the memory limit, but still gets the error.

All I have in my database is 100 records of Name, Address, Phone, & Email fields.

psychoactive

unread,
Oct 25, 2009, 4:01:30 PM10/25/09
to dompdf
Increase the memory limit to like 1000MB that's what I had to do

Fun
Uncle
Car
Kyte

On Oct 23, 6:51 pm, "Heather V." <toa...@gmail.com> wrote:
> Interesting you say that because I'm still having problems.
> "Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 77255405 bytes) inC:\...on line135"I have this:

Heather V.

unread,
Nov 2, 2009, 6:27:06 PM11/2/09
to dom...@googlegroups.com
Thanks for trying to help, psychoactive, but I get the same error. Just a change in numbers:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 77255405 bytes) in C:\....php on line 134

I could really use some help!

psychoactive

unread,
Nov 2, 2009, 6:43:33 PM11/2/09
to dompdf
You did not increase the memory limit.

134,217,728 bytes = 128 megabytes

It's still 128 megabytes, see?

It will work once you get that increased, unless your document is
hundreds of pages long and full of tables or something...

Heather V.

unread,
Nov 2, 2009, 7:06:52 PM11/2/09
to dom...@googlegroups.com
So you're referring to the php.ini file? I've changed it to 1000M.  I've also hanged this within my page, which gave me the error:

Fatal error
: Allowed memory size of 1048576000 bytes exhausted (tried to allocate 618044837 bytes) in C:\....php on line 134

$old_limit = ini_set("memory_limit", "1000M");
$dompdf = new DOMPDF(); //***THIS IS LINE 163***

$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("roster.pdf");

I've increased it to 2000M and all I get is a blank page.

There are 92 records for the code to process (just simple name, address, phone, etc.). All text, no images.

BrianS

unread,
Nov 3, 2009, 1:45:47 PM11/3/09
to dompdf
On Nov 2, 7:06 pm, "Heather V." <toa...@gmail.com> wrote:
> So you're referring to the php.ini file? I've changed it to 1000M.  I've also hanged this within my page, which gave me the error:
> Fatal error: Allowed memory size of 1048576000 bytes exhausted (tried to allocate 618044837 bytes) inC:\....phpon line134$old_limit = ini_set("memory_limit", "1000M");
> $dompdf = new DOMPDF(); //***THIS IS LINE 163***
> $dompdf->load_html($html);
> $dompdf->render();
> $dompdf->stream("roster.pdf");
> I've increased it to 2000M and all I get is a blank page.
> There are 92 records for the code to process (just simple name, address, phone, etc.). All text, no images.

Are you using tables to format the document? This can have a
significant affect on the memory footprint and the speed of rendering.

One possible work-around (which I have used successfully) ... if you
know where each page break needs to occur you can render each page
separately then use pdftk to combine them all.

psychoactive

unread,
Nov 3, 2009, 1:54:52 PM11/3/09
to dompdf
I can't imagine, even with tables, that 93 records (rows) would fail
to render. If you limit the records to 10 or something, does it
work?

me me

unread,
Nov 3, 2009, 2:19:53 PM11/3/09
to dom...@googlegroups.com
I ran into an issue of Large renders failing, and it turned out to be a large textarea that spanned more than one page. Upon furhter testing I saw a number of HTML tags expanded over more than one page break would break DOMPDF, and break it in a silent way.

maybe this helps.

Heather V.

unread,
Nov 3, 2009, 3:21:33 PM11/3/09
to dom...@googlegroups.com
I am using tables, no large textareas, how does pdftk work?

psychoactive

unread,
Nov 3, 2009, 5:48:40 PM11/3/09
to dompdf
pdftk is a command line utility that can split, merge, and do other
things to pdf files. it can also add/adjust security settings and i
think even encryption, but I am not sure.

Check it out - http://www.accesspdf.com/pdftk/



On Nov 3, 12:21 pm, "Heather V." <toa...@gmail.com> wrote:
> I am using tables, no large textareas, how does pdftk work?
> BrianS wrote:On Nov 2, 7:06 pm, "Heather V."<toa...@gmail.com>wrote:So you're referring to the php.ini file? I've changed it to 1000M.  I've also hanged this within my page, which gave me the error: Fatal error: Allowed memory size of 1048576000 bytes exhausted (tried to allocate 618044837 bytes) inC:\....phpon line134$old_limit = ini_set("memory_limit", "1000M"); $dompdf = new DOMPDF(); //***THIS IS LINE 163*** $dompdf->load_html($html); $dompdf->render(); $dompdf->stream("roster.pdf"); I've increased it to 2000M and all I get is a blank page. There are 92 records for the code to process (just simple name, address, phone, etc.). All text, no images.Are you using tables to format the document? This can have a significant affect on the memory footprint and the speed of rendering. One possible work-around (which I have used successfully) ... if you know where each page break needs to occur you can render each page separately then use pdftk to combine them all.

BrianS

unread,
Nov 3, 2009, 5:54:49 PM11/3/09
to dompdf
On Nov 3, 3:21 pm, "Heather V." <toa...@gmail.com> wrote:
> On Nov 3, 10:45 am, BrianS <eclecticg...@gmail.com> wrote:
> > Are you using tables to format the document? This can have a
> > significant affect on the memory footprint and the speed of rendering.
>
> > One possible work-around (which I have used successfully) ... if you
> > know where each page break needs to occur you can render each page
> > separately then use pdftk to combine them all.
>
> I am using tables, no large textareas, how does pdftk work?

I would guess your tables are causing the problem, particularly if
you're using nested table and/or tables that span multiple pages. If
you can simplify your document in any way that may be easier than
inserting pdftk into your workflow. One way you might simplify things
for DOMPDF is to start a new table with each record rather than just a
new row.

However, if you think pdftk may be worth investigating here's a little
info ...

pdftk (PDF toolkit) is a program that can modify PDF files in a
variety of ways. You can find it at:
http://www.accesspdf.com/pdftk/

Typically when I use it I have a document that uses a very structured
format, so I know where each page will break. In this instance I
render each page separately through a loop and save the results to a
file. When all the pages have been rendered I pass the results to
pdftk to make a single PDF file out of the individual pages. Here's
some simplified code that's along the lines of what my script does:

// $document is an array of pages for the document being rendered
$exec_cmd = 'pdftk';
foreach ($document as $index => $page) {
$dompdf = new DOMPDF();
$dompdf->load_html($page);
$dompdf->render();
file_put_contents('tempfile' . $index . '.pdf', $dompdf->output());
unset($dompdf);
$exec_cmd .= ' tempfile' . $index . '.pdf';
}
$exec_cmd .= ' cat output final.pdf';
exec($exec_cmd, $pdftk_output, $pdftk_return_code);

You can find a sample of my script here:
http://eclecticgeek.com/code/dompdf.txt
Reply all
Reply to author
Forward
0 new messages