2014-07-07 90 views
0

我正在使用tcpdf創建pdf,並且我想在頁腳中添加版權文本,但此頁腳文本顯示在標題上方。下面是代碼如何在tcpdf庫中添加頁腳

$this->MultiCell(0, 10, $wpptopdfopts['pdf_footer'], 0, false, 'C', 0, '', 0, false, 'T', 'M'); 

回答

0

1.創建類擴展TCPDF類:

class YourPdfGenerator extends TCPDF {} 

2.Overwrite頁腳方法與您的數據:

public function Footer() { 
    [...] 
    $pagenumtxt = $this->l['w_page'] . ' ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(); 
    $this->SetDrawColor(128, 128, 128); 
    $this->Line(10, 264, 200, 264); 
    $this->SetFont('myfont', '', 6); 
    $this->SetTextColor(80, 80, 80); 
    $this->SetXY(10, -32); 
    $this->MultiCell(190, 10, $this->locale($this->lang->trans('report_label_offer_policy')), 0, 'L'); 
    $this->SetFont('myfont', '', 8); 
    $this->SetXY(10, -14); 
    $this->Cell(192, 10, $this->locale($date_now), 0, 0, 'L'); 
    $this->SetXY(10, -14); 
    $this->Cell(190, 10, $pagenumtxt, 0, 0, 'R'); 
    } 

3.Enjoy