[英]How to retrieve current page HTML code from Footer() method in TCPDF?
我正在使用TCPDF呈現一些通過一系列HTML表生成的報告。 這些表包含一些我想從Footer()方法解析並添加到當前頁腳的跟蹤代碼。 任何想法如何從TCPDF獲取當前頁面的html代碼?
我基本上是這樣做的:
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');
我發現的唯一解決方案是使用標記定義我添加到上述SVNPDF類中的方法。 然后,TCPDF將使用tracking in參數調用此方法。
這是快照:
<tcpdf method="my_custom_func" params="'.TCPDF_STATIC::serializeTCPDFtagParameters(array('tracking number here')).'" />
並在SVNPDF類中:
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
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.