1

我有一个带有 THEAD 输出的 html 表,writeHTML它应该显示在表顶部的每个页面上。它可以工作,但是当我使用由 FPDI 加载的模板时,头部是白色的,并且在第二页和更远的地方消失了。我可以用鼠标标记头部字段,但显示为白色。边框仅显示为左侧的一个小点。

我已经尝试添加$this->setPageMark()到该addPage方法中。但它仍然是同样的问题。

public function AddPage($orientation = '', $format = ''){
    parent::AddPage($orientation, $format);
    if($this->template != null){
        $this->useTemplate($this->template);
        $this->setPageMark();
    }
}
4

1 回答 1

0

您需要在开始时启用分页符,这会导致您遇到的问题;这是一个示例代码片段;

require_once('tcpdf/tcpdf.php'); //main code    
require_once('tcpdf/fpdi.php');  //read existing pdf and sends to fpdf
$pdf = new FPDI();
$pdf->setPrintHeader(false); //no header
$pdf->setPrintFooter(false);//no footer    
$pdf->SetAutoPageBreak(FALSE, 0); // set auto page breaks
//loop starts here
{ 
    $pdf->setSourceFile($page_background); //set page                                                                                                                                                             
    $templateId = $pdf->importPage(1); //we only need the first page                                                                                   
    $pdf->useTemplate($templateId);     //use the imported page
    //your write html code and any other tcpdf related code comes here
}
$pdf->Output(outcome.pdf, 'I'); //use F instead of I  to show generated pdf. 
于 2016-09-08T20:52:12.200 回答