2015-08-28 34 views
2

我想設置tcpdf中右邊距的顏色。這是代碼:每頁的tcpdf顏色

$bMargin = $pdf->getBreakMargin(); 

// get current auto-page-break mode 

$auto_page_break = $pdf->getAutoPageBreak(); 

// disable auto-page-break 

$pdf->SetAutoPageBreak(false, 0); 

$pdf->Rect(0, 0, 10, 1000,'F',array(),array(199, 245, 206)); 

$pdf->SetAutoPageBreak($auto_page_break, $bMargin); 

// set the starting point for the page content 

$pdf->setPageMark(); 

問題是,彩色右邊距只顯示在第一頁上。我希望它在所有頁面上顯示。我該如何解決它?

+0

好的,我解決了它。只需將其放在公共功能標題 –

回答

0
class MYPDF extends TCPDF { 

    //Page header 
    public function Header() { 
     // Logo 


     $image_file = K_PATH_IMAGES.'logo_example.jpg'; 

     //$this->Image($image_file, 10, 5, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false); 

     // Set font 

     $this->SetFont('helvetica', 'B', 20); 

     $this->Rect(0, 0, 1000, 10,'F',array(),array(199, 245, 206)); 

     $this->SetTextColor(0, 0, 50); 

     // Title 

     $this->Cell(0, 15, 'mysite', 0, false, 'C', 0, '', 0, false, 'M', 'M'); 

     $bMargin = $this->getBreakMargin(); 

// get current auto-page-break mode 

$auto_page_break = $this->getAutoPageBreak(); 

// disable auto-page-break 

$this->SetAutoPageBreak(false, 0); 

$this->Rect(0, 0, 13, 1000,'F',array(),array(199, 205, 206)); 

$this->SetAutoPageBreak($auto_page_break, $bMargin); 

// set the starting point for the page content 

$this->setPageMark(); 

    } 

    // Page footer 
    public function Footer() { 
     // Position at 15 mm from bottom 
     $this->SetY(-15); 
     // Set font 

     $this->SetFont('helvetica', 'I', 8); 
     $this->SetTextColor(150, 50, 50); 
     // Page number 
     $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); 
    } 

} 
+0

內但不能編輯頁腳的背景 –