PHP TCPDF remove header's bottom border

前端 未结 5 1694
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 21:06

I am trying to create a header in TCPDF, however it always have a border underneath of it. Is there a way I can remove the bottom border?

相关标签:
5条回答
  • 2020-12-30 21:47

    tcpdf.php:

    // print an ending header line
    $this->SetLineStyle(array('width' => 0.25 / $this->k, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 255, 255)));
    
    0 讨论(0)
  • 2020-12-30 21:50

    Problem solved by extends the TCPDF class and modify the header and footer.

    class MYPDF extends TCPDF { 
    
        public function Header() 
        { 
            $image_file = K_PATH_IMAGES.'pdf-header.jpg'; 
            $this->Image($image_file, 160, 10, 40, '', 'JPG', '', 'T', false, 20, '', false, false, 0, false, false, false); 
            $this->SetFont('helvetica', 'B', 10); 
        } 
    
        public function Footer() 
        { 
            $this->SetY(-15); 
            $this->SetFont('helvetica', 'I', 8); 
    
        }
    }
    
    0 讨论(0)
  • 2020-12-30 21:51

    This works for some versions:

    // Call before the addPage() method
    $pdf->SetPrintHeader(false);
    $pdf->SetPrintFooter(false);
    
    0 讨论(0)
  • 2020-12-30 21:51

    Comment this line in Header() function of tcpdf Class :

    $this->Cell(($this->w - $this->original_lMargin - $this->original_rMargin), 0, '', 'T', 0, 'C');
    
    0 讨论(0)
  • 2020-12-30 22:05

    If you don't want to subclass or change the tcpdf source just call the setHeaderData method and specify white line color.

    $pdf->setHeaderData('',0,'','',array(0,0,0), array(255,255,255) );  
    
    0 讨论(0)
提交回复
热议问题