Dom PDF Problem
am 02.07.2009 12:59:01 von p4pravin
------=_NextPart_000_0001_01C9FB32.383FC650
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hey all,
I am working with generating PDF using Dom PDF.
My problem is when I generate a single PDF , Its working fine.
But when I code it in a loop for generating more than one PDF it gives some
error.
$DomObj = new DOMPDF();
$DomObj->load_html_file($pth);
$DomObj->render();
$pdf = $DomObj->output();
file_put_contents($MainDir."/Order-".$rsOrder[$ro]['OrderNum ber']."/packing_
slip.pdf", $pdf);
the above code is in a loop
I come to know that ,there is problem with memory leak.
Also I thought that it was because I had not destroy the previously created
Object.
So I also tried destroying it using unset.. I don't know whether its
destroying or not.
Error is something like
"Fatal error: Uncaught exception 'DOMPDF_Exception' with message 'No
block-level parent found. Not good.' in
D:\foldername\project\control\dompdf\include\inline_position er.cls.php:68
Stack trace: #0 D:\foldername\ project
\control\dompdf\include\frame_decorator.cls.php(381):
Inline_Positioner->position() #1 D:\foldername\ project
\control\dompdf\include\inline_frame_reflower.cls.php(56):
Frame_Decorator->position(".........
Can anyone please give me some way to solve this.
------=_NextPart_000_0001_01C9FB32.383FC650--
Re: Dom PDF Problem
am 02.07.2009 16:08:10 von Paul M Foster
On Thu, Jul 02, 2009 at 04:29:01PM +0530, Pravinc wrote:
> Hey all,
>
> I am working with generating PDF using Dom PDF.
>
> My problem is when I generate a single PDF , Its working fine.
>
> But when I code it in a loop for generating more than one PDF it gives some
> error.
>
> $DomObj = new DOMPDF();
>
> $DomObj->load_html_file($pth);
>
> $DomObj->render();
>
> $pdf = $DomObj->output();
>
> file_put_contents($MainDir."/Order-".$rsOrder[$ro]['OrderNum ber']."/packing_
> slip.pdf", $pdf);
>
> the above code is in a loop
>
> I come to know that ,there is problem with memory leak.
>
> Also I thought that it was because I had not destroy the previously created
> Object.
>
> So I also tried destroying it using unset.. I don't know whether its
> destroying or not.
>
> Error is something like
>
> "Fatal error: Uncaught exception 'DOMPDF_Exception' with message 'No
> block-level parent found. Not good.' in
> D:\foldername\project\control\dompdf\include\inline_position er.cls.php:68
> Stack trace: #0 D:\foldername\ project
> \control\dompdf\include\frame_decorator.cls.php(381):
> Inline_Positioner->position() #1 D:\foldername\ project
> \control\dompdf\include\inline_frame_reflower.cls.php(56):
> Frame_Decorator->position(".........
>
> Can anyone please give me some way to solve this.
>
I had an error something like this when using FPDF. It would hack up the
second PDF. I didn't investigate it a lot, but my solution was to
instantiate the class *once*, and loop on the *rest* of it.
Paul
--
Paul M. Foster
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Dom PDF Problem
am 23.09.2009 15:48:00 von Chris Wilson
--=======AVGMAIL-69DB660C=======
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
This might help some people struggling with memory leak problems in
DOMPDF. I haven't fixed it but it seems to have reduced the memory leak
considerably.
I have done 2 things:
1.
Added a detruct function to the DOMPDF file in dompdf.cls.php where I
unset everything. I call this each time in my loop when I'm using DOMPDF
mulitple times:
function __destruct()
{
unset($this->_messages);
unset($this->_xml);
unset($this->_tree);
unset($this->_css);
unset($this->_pdf);
unset($this->_paper_size);
unset($this->_paper_orientation);
unset($this->_base_host);
unset($this->_base_path);
unset($this->_cache_id);
}
2.
I now added within the render function of DOMPDF a call to the function
dispose to clean up anything left from before:
// This is where the magic happens:
$root->reflow();
=09
// Memory leak fix
$root->dispose(true);
// Clean up cached images
Image_Cache::clear();
Also worth mentioning that I increased my memory allocation in my
php.ini to about 256MB, and the max execution time to about 120 seconds.
As mentioned this won't fix the problem but it does reduce the memory
used.
Chris
No virus found in this outgoing message.
Checked by AVG - www.avg.com=20
Version: 8.5.416 / Virus Database: 270.13.112/2388 - Release Date:
09/23/09 05:52:00
--=======AVGMAIL-69DB660C=======
Content-Type: multipart/alternative;
boundary="=======AVGMAIL-1ABE0A76======="
--=======AVGMAIL-1ABE0A76=======
Content-Type: text/plain; x-avg=cert; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Content-Description: "AVG certification"
No virus found in this outgoing message.
Checked by AVG - www.avg.com
Version: 8.5.416 / Virus Database: 270.13.112/2390 - Release Date: 09/23/09 =
05:52:00
--=======AVGMAIL-1ABE0A76=======--
--=======AVGMAIL-69DB660C=======
Content-Type: text/plain; charset=us-ascii
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--=======AVGMAIL-69DB660C=======--