Page Numbers in Footer

2,814 views
Skip to first unread message

Nathan Carter

unread,
May 29, 2018, 9:08:53 AM5/29/18
to dompdf
I have been trying to get page numbers in the footer of my document without any luck. I am using dompdf 0.8.2.


My instantiation code is:
$dompdf = new Dompdf();
$options
= new \Dompdf\Options();
$options
->set('isPhpEnabled', true);
$options
->set('defaultFont','Helvetica');
$dompdf
->setOptions($options);

My inline php is:
Enter <script type="text/php">
if (isset($pdf))
{
$x
= 760;
$y
= 561;
$text
= "Page {PAGE_NUM} of {PAGE_COUNT}";
$font
= $fontMetrics->get_font("Helvetica", "bold");
$size
= 8;
$color
= array(0,0,0);
$word_space
= 0.0;
$char_space
= 0.0;
$angle
= 0.0;
$pdf
->page_text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle);
}
</script>

I output my PDF with:
$dompdf->loadHtml($html);
$dompdf
->setPaper('A4', 'portrait');
$dompdf
->render();
$dompdf
->stream('gtwbimport'.$filedate.'.pdf');

The $html variable is generated dynamically in the script (with values from a database, etc).

The PDF is generated and displayed but there is no footer with the page number, etc.

I have tried to look at the samples mentioned in the documentation (that are in the test/ directory) but I don't have a test directory nor can find any release of 0.8.x with it.

Nathan Carter

unread,
Jun 3, 2018, 6:27:38 AM6/3/18
to dompdf
Just reporting back that I have resolved the issue.

After looking at the page height and width using the canvas, I realised that the x,y variables I were off the page.
Reply all
Reply to author
Forward
0 new messages