Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Paging with DOMPDF

2,895 views
Skip to first unread message

Guilherme S Zanoni

unread,
Aug 25, 2010, 8:12:44 AM8/25/10
to dompdf
Hi Guys, I need your support regarding to put number of page.

This sample on the website of class dompdf, are exactly what I need.

http://www.digitaljunkies.ca/dompdf/test/demo_01.pdf

On the bottom are number of page:

Page 1 of 1

How can I put this on the my reports?

Can you help me please?

Fabien Ménager

unread,
Aug 25, 2010, 8:19:16 AM8/25/10
to dompdf
Hello, please read the FAQ : http://code.google.com/p/dompdf/wiki/FAQ
this feature is explained in the 4th point.
You should also download the 0.6beta version and browse the example
files in which the example you linked is also present.

Guilherme S Zanoni

unread,
Aug 25, 2010, 8:36:17 AM8/25/10
to dompdf
Ok my friend, tkx..

Just one thing.. Where I found version 0.6beta to download?

Thank you all.
> > Can you help me please?- Hide quoted text -
>
> - Show quoted text -

Fabien Ménager

unread,
Aug 25, 2010, 8:56:07 AM8/25/10
to dompdf
It is here : http://code.google.com/p/dompdf/downloads/list
Did you already download a zip ? If so, where did you download it
from ?

Guilherme S Zanoni

unread,
Aug 25, 2010, 9:00:57 AM8/25/10
to dompdf
Perfect..

I found the functions that I need to use:

<script type="text/php">

if ( isset($pdf) ) {

$font = Font_Metrics::get_font("verdana");;
$size = 6;
$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();

// Draw a line along the bottom
$y = $h - $text_height - 24;
$pdf->line(16, $y, $w - 16, $y, $color, 0.5);

$pdf->close_object();
$pdf->add_object($foot, "all");

$text = "Page {PAGE_NUM} of {PAGE_COUNT}";

// Center the text
$width = Font_Metrics::get_text_width("Page 1 of 2", $font, $size);
$pdf->page_text($w / 2 - $width / 2, $y, $text, $font, $size,
$color);

}
</script>

I think is that this. But in all samples, it never are calling.
> > > - Show quoted text -- Hide quoted text -

Guilherme S Zanoni

unread,
Aug 25, 2010, 1:43:57 PM8/25/10
to dompdf
Somebody can help me on this?

Please!!

BrianS

unread,
Aug 31, 2010, 2:59:42 PM8/31/10
to dompdf
Make sure you have enabled inline script by setting DOMPDF_ENABLE_PHP
to true. Then, you should also make sure that the inline script is in
the BODY of your document. If it is outside the body DOMPDF will
ignore it.

Alwin Pacheco

unread,
Oct 2, 2019, 8:51:22 AM10/2/19
to dompdf
Message from the future: In 0.7.0 FontMetrics class is now instantiated and available as $fontMetrics. The wiki will be updated when we merge the develop branch back in to master.

Reply all
Reply to author
Forward
0 new messages