I'm using TCPDF to render some report generated through a sequence of HTML tables. These tables contain some tracking code I want to parse from Footer() method and add to current page footer. Any idea how to get the html code of the current page from TCPDF ?
I'm basically doing this:
class SVNPDF extends TCPDF {
// Page footer
public function Footer() {
// Position at 15 mm from bottom
$this->SetY(-15);
// Set font
$this->SetFont('helvetica', 'I', 10);
// Page number
$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'R', 0, '', 0, false, 'T', 'M');
$this->SetY(-15);
$this->SetFont('helvetica', 'I', 10);
$this->Cell(0, 10, 'Picking #'.$glb_picking_num.'', 0, false, 'L', 0, '', 0, false, 'T', 'M');
// HERE I NEED TO RETRIEVE CURRENT PAGE HTML CONTENT AND EXTRACT THE TRACKING NUMBER INSIDE FOR DISPLAY IN CURRENT FOOTER
}
}
$report = 'SOME LONG HTML CODE HERE';
$pdf = new SVNPDF('L', 'mm', 'A4', true, 'UTF-8', false);
$pdf->AddPage();
$pdf->writeHTML($report, true, false, true, false, '');
$pdf->Output(dirname(__FILE__) . '/test.pdf', 'I');
The only solution I found was to use the tag to define a method I added to the SVNPDF class above. Then TCPDF will call this method with the tracking in parameter.
Here's a snapshot:
<tcpdf method="my_custom_func" params="'.TCPDF_STATIC::serializeTCPDFtagParameters(array('tracking number here')).'" />
and in SVNPDF class:
public function my_custom_func( $tracking_num ){
$cur_page = $this->PageNo();
// I can now store the $tracking_num in some private array and retrieve it in the Footer() as per current page number
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.