PHP TCPDF 删除标题的底部边框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7950493/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP TCPDF remove header's bottom border
提问by Bill
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?
我试图在 TCPDF 中创建一个标头,但是它下面总是有一个边框。有没有办法去除底部边框?
采纳答案by Patrik Ján
tcpdf.php:
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)));
回答by András
This works for some versions:
这适用于某些版本:
// Call before the addPage() method
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
回答by James
If you don't want to subclass or change the tcpdf source just call the setHeaderData
method and specify white line color.
如果您不想子类化或更改 tcpdf 源,只需调用该setHeaderData
方法并指定白线颜色。
$pdf->setHeaderData('',0,'','',array(0,0,0), array(255,255,255) );
回答by Bill
Problem solved by extends the TCPDF class and modify the header and footer.
通过扩展TCPDF类并修改页眉和页脚解决的问题。
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);
}
}
回答by Rkk
Comment this line in Header() function of tcpdf Class :
在 tcpdf Class 的 Header() 函数中注释这一行:
$this->Cell(($this->w - $this->original_lMargin - $this->original_rMargin), 0, '', 'T', 0, 'C');