I did try creating the DOMPDF instance once, and then just reusing it,
but that didn't work either. The second call results in a fatal error
"Uncaught exception 'DOMPDF_Exception' with message 'No block-level
parent found..."
Does anyone know how I can call DOMPDF more than once from within a
script? Is there something I need to clear, reinitialize, etc?
I'm using version dompdf-0.5.1.
Thanks!
-jheske
The DOMPDF object definitely doesn't like to be re-used, as you have
seen. In the past I have done something similar to your current setup.
Have you tried using unset() on the DOMPDF object? This was the trick
for me.
Are you seeing any errors in your PHP error.log? What about your
Apache error.log? Typically a connection reset from an Apache server
means the child process crashed. The resources assigned to DOMPDF
might not be released with the way you currently have your script
coded. This could, perhaps, be the reason Apache is having problems
(though I haven't confirmed this to be a problem).
A way you could code your script that would definitely release
resources would be to create a separate PHP script that runs the
DOMPDF tasks. Call it using exec() and all the resources associated
with each instance would be released on each loop. See the following
discussion for reference:
http://groups.google.com/group/dompdf/browse_thread/thread/c253a52b10766a33/4211bcedbf9cf40?q=
One thing which isn't mentioned in that discussion and is worth pointing
out is that you will need to be *extremely* careful about passing
arguments to exec, especially if they come from user input. In my script
all the information comes from a pre-populated database table, so I know
what the data is.
Also, if you are on a virtual hosting platform, the exec function might
(and should in my opinion) be disabled.
Paul
--
Paul Waring
http://www.pwaring.com
What do you see in the logs? Information which appears unhelpful at
first can still sometimes help track down what the problem is.
> I''ve tried to run my script using exec() but with no luck. I just
> haven't been able to figure out how to use exec to call a PHP script.
> I'm testing in Windows XP. Here's my exec() command:
>
> exec ("c:\\program files\\php\\php.exe mydompdf.php",$retval);
>
> mydompdf.php is just a simple test script that doesn't take any params
> but creates a canned pdf file from some sample html text.
> Unfortunately, the test pdf doesn't get created and exec() doesn't
> return anything ($retval is an empty array), so I have no idea what my
> error is.
What happens if you try running the script on the command line, i.e.
without using exec?