Skip to content

Instantly share code, notes, and snippets.

@bsweeney
Forked from anonymous/gist:7661439
Last active December 29, 2015 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsweeney/7661613 to your computer and use it in GitHub Desktop.
Save bsweeney/7661613 to your computer and use it in GitHub Desktop.
$dompdf = new DOMPDF;
$dompdf->load_html('<p>hello world</p><p style="page-break-before: always;">hello again</p>');
$dompdf->get_canvas()->page_script('
if ($PAGE_COUNT > 1) {
$font = Font_Metrics::get_font("yourfont", "normal");
$size = 9;
$pageText = "Page " . $PAGE_NUM . " of " . $PAGE_COUNT;
$y = $pdf->get_height() - 24;
$x = $pdf->get_width() - 15 - Font_Metrics::get_text_width($pageText, $font, $size);
$pdf->text($x, $y, $pageText, $font, $size);
}
');
$dompdf->render();
$dompdf->stream();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment