douyun3799 2013-10-14 13:40
浏览 95
已采纳

如何从TCPDF中的Footer()方法中检索当前页面HTML代码?

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');
  • 写回答

1条回答 默认 最新

  • doumeng4400 2013-10-14 18:19
    关注

    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
            }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路