I have achieved this in Drupal and assume that it works with other php opensource and frameworks. I saved this code inside the script tag
$GLOBALS['entity_page'][] = $pdf->get_page_number();
in the template in which the page number is stored. Template with extension tpl.php Now in the module after other codes for export I added ......
$canvas = $dompdf->get_canvas(); $font = Font_Metrics::get_font("helvetica", "normal"); $canvas->page_text(520, 805, "Page {PAGE_NUM}", $font, 9, array(0.4, 0.4, 0.4)); foreach ($GLOBALS['entity_page'] as $key => $val) { $GLOBALS["entity_val"] = 0; $GLOBALS["entity_y"] = 110; $canvas->page_script('if($PAGE_NUM == 3 && $PAGE_NUM < 4){ $font = Font_Metrics::get_font("helvetica", "normal"); $x = 380; $y = $GLOBALS["entity_y"]; $pdf->text($x, $y, "-------------------------".$GLOBALS["entity_page"][$GLOBALS["entity_val"]]."", $font, 12, array(0, 0, 0, 0.8)); $GLOBALS["entity_y"] = $GLOBALS["entity_y"] + 33; $GLOBALS["entity_val"] = $GLOBALS["entity_val"] + 1; }'); }
$ pdf-> text This part adds page numbers in constant increment at the y axis position. Other global variables entity_y and entity_val are used to store values.
source share