2010-05-13 105 views

回答

0

之后EOD使用下面的代码覆盖页脚方法。

EOD; 

$txt = date("m/d/Y h:m:s");  

// print a block of text using Write() 
$pdf->Write($h=0, $txt, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0); 
0

我想通了,这里是可能会遇到此线程的其他人的解决方案。

编辑文件“tcpdf.php”。

搜索 “public function Footer()

Add(添加)时间戳:

$timestamp = date("m/d/Y h:m:s"); 

if (empty($this->pagegroups)) { 

$pagenumtxt = ' Created on ' .$timestamp.' '.$this->l['w_page'].' '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(); 

} else { 

$pagenumtxt = ' Created on ' .$timestamp.' '. $this->l['w_page'].' '.$this->getPageNumGroupAlias().'/'.$this->getPageGroupAlias(); 

} 
+0

这引起了否决,因为它是更好的扩展类并覆盖比编辑在这种回答表明源的方法HTH – TheDavidFactor 2015-10-19 02:56:09

5

您必须扩展TCPDF类并覆盖页脚()方法的默认实例中,n解释。 3.检查官方http://www.tcpdf.org网站和论坛获取更多信息。

17

覆盖类是这样的:

class MYPDF extends TCPDF { 
    public function Footer() { 
     $image_file = "img/bg_bottom_releve.jpg"; 
     $this->Image($image_file, 11, 241, 189, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false); 

     $this->SetY(-15); 
     $this->SetFont('helvetica', 'N', 6); 
     $this->Cell(0, 5, date("m/d/Y H\hi:s"), 0, false, 'C', 0, '', 0, false, 'T', 'M'); 
    } 
} 

然后,而不是调用:

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

做:

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

如果你想要把多个页面上的不同内容:

define("bottom_info", "|FIRST PAGE|SECOND PAGE|THIRD PAGE|...", true); 

该信息将被“|” “(与爆炸功能)

类:

class MYPDF extends TCPDF { 

public function Header() { 
} 

// Page footer 
public function Footer() { 
    $this->SetY(-15);  
    $this->SetFont('helvetica', '', 7); 
    // Page number  
    $titulos = explode("|",bottom_info);   
    $this->Cell(0, 10, $titulos[$this->page].' - Pagina '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); 
} 

}