Is it possible to get the y position of the last HTML element when rendering an HTML document to a PDF with Dompdf?
I need to insert an element after pdf rendering at the end of my document (fields for digital signature)...
EDIT : As described in DOMPDF Github https://github.com/dompdf/dompdf/issues/1424 , you need to create a callback for the event 'end_frame' :
$dompdf = new Dompdf();
$dompdf->setCallbacks(
array(
'myCallbacks' => array(
'event' => 'end_frame', 'f' => function ($infos) {
$frame = $infos["frame"];
// elements positions
$GLOBALS["array_coord"][] = $frame->get_padding_box();
// last page number
$counter_frame = $frame->lookup_counter_frame('page');
$page_number = $counter_frame->counter_value('page');
}
)
)
);
and then after the rendering :
$dompdf->render();
// get the last y position in the PDF
$ligne_sign = sizeof($GLOBALS["array_coord"]) - 2;
$y = $GLOBALS["array_coord"][$ligne_sign]["y"];