Using DOMPDF inside Joomla CMS

760 views
Skip to first unread message

Nailson

unread,
Sep 8, 2009, 5:45:22 PM9/8/09
to dompdf
Hi all,

I am needing to export some content to PDF format from inside Joomla
CMS. I started with DomPDF some days ago and actually I am being able
to generate some great PDFs( external css!!!!!!!! ). However, I can't
generate files with more than 6k of size and I can't add footers or
headers to the file because I am not getting any access to the
CPDF_Adapter instance. I am using this code:

<script type="text/php" >
$font = Font_Metrics::get_font("verdana");
$size = 10;
$color = array(0,0,0);
$text_height = Font_Metrics::get_font_height($font, $size);
$foot = $pdf->open_object();
$w = $pdf->get_width();
$h = $pdf->get_height();
$y = $h - 2 * $text_height - 24;
$pdf->line(16, $y, $w - 16, $y, $color, 1);
$y += $text_height;
$text = "My Awesome Website! (edit PdfExport_headfoot.php to change
this text) | " . date("F j, Y");
$pdf->text(16, $y, $text, $font, $size, $color);
$pdf->close_object();
$pdf->add_object($foot, "all");
$text = "Page {$PAGE_NUM}/{$PAGE_COUNT}";
$width = Font_Metrics::get_text_width($text, $font, $size);
$pdf->page_text($w-5 - $width, $y, $text, $font, $size, $color);
</script>

But this script never runs or something. I end having the same
document that I have when I don't add script tags to the html file.
May someone help me out of this?

Also, I tried to access the digitaljunkies website these days and it's
not there...

BrianS

unread,
Sep 9, 2009, 2:31:06 PM9/9/09
to dompdf
On Sep 8, 5:45 pm, Nailson <nailson.l.olive...@gmail.com> wrote:
> I am needing to export some content to PDF format from inside Joomla
> CMS. I started with DomPDF some days ago and actually I am being able
> to generate some great PDFs( external css!!!!!!!! ). However, I can't
> generate files with more than 6k of size

Do you see any errors in your log files? DOMPDF may be exceeding your
memory or execution time limits. Try increasing these to see what
happens.

> I can't add footers or headers to the file because I am not getting
> any access to the CPDF_Adapter instance.

Do you have DOMPDF_ENABLE_PHP set to true? This setting can be found
in dompdf_config.inc.php. Also, make sure that your inline script is
contained within the body of your HTML document, otherwise it won't
execute.

> Also, I tried to access the digitaljunkies website these days and it's
> not there...

Benj is not actively developing DOMPDF right now. His site has been
offline on occasion lately, but I'm not sure what's going on (I
haven't talked to him). Almost all the content from the digitaljunkies
site can be found on code.google.com/dompdf. The one piece of
documentation that's missing is the API documentation.

-b

Nailson

unread,
Sep 9, 2009, 7:29:29 PM9/9/09
to dompdf
Thanks for your reply. I just managed to execute some php code, but
I'm not getting the best results at all.
I can't even test it properly because the document are being generated
with some problems.
When I create the pdf with just some lines of data, the document
displays, but when I add some more data the document doesn't displays
and I get this error message: "Adobe Reader could not open 'test.pdf'
because it is either not a supported file or because the file has been
damaged"

Is there any guide I should follow when creating pdfs to assure that
the document will display fine?

Also, is it normal that the pdf generating process take a long time to
display even small files?

BrianS

unread,
Sep 11, 2009, 1:08:18 PM9/11/09
to dompdf
On Sep 9, 7:29 pm, Nailson <nailson.l.olive...@gmail.com> wrote:
> Thanks for your reply. I just managed to execute some php code, but
> I'm not getting the best results at all.
> I can't even test it properly because the document are being generated
> with some problems.
> When I create the pdf with just some lines of data, the document
> displays, but when I add some more data the document doesn't displays
> and I get this error message: "Adobe Reader could not open 'test.pdf'
> because it is either not a supported file or because the file has been
> damaged"

I don't see anything in your code that would cause this kind of error.
I created a simple document that contains the script you posted and
Acrobat was able to open it just fine. Do you have a sample of the
code that is causing problems?

> Is there any guide I should follow when creating pdfs to assure that
> the document will display fine?

Beyond what is available in the FAQ there's not a lot out there. If
your HTML is syntactically correct and you are not running into any of
the bugs that causes DOMPDF to error out your document should render.
It may, perhaps, not look quite right if you are using unsupported
styling, but it should at least display.

You could try looking for some FAQs developed by users (such as those
on Luca's site at http://luca.priorelli.com/). But otherwise there's
not much available.

> Also, is it normal that the pdf generating process take a long time to
> display even small files?

This really depends on the nature of your HTML document and your
system specs. Typically it should not take very long at all for a
simple document, but if you have tables (and particularly nested
tables) it can add significant time to the rendering process.

psychoactive

unread,
Sep 11, 2009, 1:15:29 PM9/11/09
to dompdf
Documents literally generate 10-20 times faster on a server than on my
desktop computer...



On Sep 11, 10:08 am, BrianS <eclecticg...@gmail.com> wrote:
> On Sep 9, 7:29 pm, Nailson <nailson.l.olive...@gmail.com> wrote:
>
> > Thanks for your reply. I just managed to execute some php code, but
> > I'm not getting the best results at all.
> > I can't even test it properly because the document are being generated
> > with some problems.
> > When I create the pdf with just some lines of data, the document
> > displays, but when I add some more data the document doesn't displays
> > and I get this error message: "Adobe Reader could not open 'test.pdf'
> > because it is either not a supported file or because the file has been
> > damaged"
>
> I don't see anything in your code that would cause this kind of error.
> I created a simple document that contains the script you posted and
> Acrobat was able to open it just fine. Do you have a sample of the
> code that is causing problems?
>
> > Is there any guide I should follow when creating pdfs to assure that
> > the document will display fine?
>
> Beyond what is available in the FAQ there's not a lot out there. If
> your HTML is syntactically correct and you are not running into any of
> the bugs that causes DOMPDF to error out your document should render.
> It may, perhaps, not look quite right if you are using unsupported
> styling, but it should at least display.
>
> You could try looking for some FAQs developed by users (such as those
> on Luca's site athttp://luca.priorelli.com/). But otherwise there's
Reply all
Reply to author
Forward
0 new messages