2017-07-27 98 views
0

我正在使用tc pdf库生成pdf。 我已经设置自定义hedar和页脚像下面在主要内容上重叠的TCPDF页脚图像

class CustomTcpdf extends \TCPDF { 

    public function Header() { 
    $headerData = $this->getHeaderData(); 
    $this->writeHTML($headerData['string'], true, false, true, false, ''); 
    } 

    public function Footer() { 
    // Position at 15 mm from bottom 
    $this->SetY(-50); 
    $image_file = 'footer.png'; 
    $this->Image($image_file, 15, 250, 183); 
    } 

} 

以下为创建代码

$tcpdf = new CustomTcpdf(); 
     $tcpdf->setHeaderData($ln = '', $lw = 0, $ht = '', $pdf_header_data, $tc = array(0, 0, 0), $lc = array(0, 0, 0)); 
      $tcpdf->AddPage('A4', 'Portrait'); 
      $tcpdf->SetFooterMargin(60); 
      //$tcpdf->setHeaderMargin(40); 
      $tcpdf->SetAutoPageBreak(TRUE, 0); 
$tcpdf->SetY(70); 
     $tcpdf->writeHTML($content, true, false, true, TRUE, ''); 

     $tcpdf->Output('HAKO.pdf', 'I'); 

输出页脚是如下 enter image description here

预期成果是, 即时重叠内容应该在下一页。

回答

0

我用下面的代码在头功能类似下面

class CustomTcpdf extends \TCPDF { 

    public function Header() { 
    $headerData = $this->getHeaderData(); 
    $this->writeHTML($headerData['string'], true, false, true, false, ''); 
    $this->SetTopMargin(70); 
    } 


} 

随着这 - > SetTopMargin(70)帮助解决问题标题和 为页脚$ tcpdf-> SetAutoPageBreak(TRUE ,65); 65是从这个2方法重叠问题的底部保证金将被解决。