2012-08-22 145 views

回答

0

如果您想更改TCPDF的工作方式,您需要覆盖页脚方法并实现您的自定义逻辑。

class CUSTOMPDF extends TCPDF { 
    public function Footer() { 

    $this->SetY(-10); 
    $this->SetFont('verdana', 'N', 9); 
    //more logic, take a look at the parent::Footer method 

} 
} 

使用它通过调用$pdf = new CUSTOMPDF(<options>);

+0

谢谢..它的工作原理 – user1490346

3
$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().' of '.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); 

必须扩展TCPDF类如下面的例子中:

class MYPDF extends TCPDF { 
     // Page footer 
     public function Footer() { 
      // Position at 15 mm from bottom 
      $this->SetY(-8); 
      // Set font 
      $this->SetFont('helvetica', 'I', 8); 
      // Page number 
      $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().' of '.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');  
     }  
    } 


$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 

$pdf->AddPage();