【问题标题】:How to retrieve current page HTML code from Footer() method in TCPDF?如何从 TCPDF 中的 Footer() 方法检索当前页面 HTML 代码?
【发布时间】:2013-10-14 13:40:43
【问题描述】:

我正在使用 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');

【问题讨论】:

    标签: php html pdf tcpdf fpdf


    【解决方案1】:

    我找到的唯一解决方案是使用标签来定义我添加到上面的 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
            }
    

    【讨论】:

      猜你喜欢
      • 2015-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-29
      • 1970-01-01
      • 2012-06-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多