PHP TCPDF 删除标头的底部边框
我试图在 TCPDF 中创建一个标头,但它下面总是有一个边框。有什么办法可以去掉底部边框吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这适用于某些版本:
This works for some versions:
如果您不想子类化或更改 tcpdf 源,只需调用 setHeaderData 方法并指定白线颜色。
If you don't want to subclass or change the tcpdf source just call the
setHeaderData
method and specify white line color.通过扩展 TCPDF 类并修改页眉和页脚解决了问题。
Problem solved by extends the TCPDF class and modify the header and footer.
tcpdf.php:
tcpdf.php:
如果此线程中发布的其他解决方案不起作用,我以这种方式解决:
TL;DR
在 Tcpdf 类 (tcpdf.php) 的 Footer() 函数中:
替换此行:
使用此行
替代方式 1
在 Tcpdf 类 (tcpdf.php) 的 Footer() 函数中注释此行:
在我的文件(版本 6.3.1)中,它们被放置在第 3524 行,
这将禁用页脚中页码的渲染,但至少会删除不需要的行。
替代方式2
如果这些方法不起作用,请在 tcpdf.php 文件中搜索以下字符串:
您应该找到 3 次出现,将数组的“color”属性替换为值
[0,0,0]
(或背景的 RGB 颜色),这应该会导致线条变成白色(或您设置的颜色)。我使用这种方法通过放置自定义奇怪的颜色并查看正在渲染哪一个来解决问题所在。
说明
线条被渲染是因为线条中的
border 属性设置为“T”(顶部边框)。您可以通过将 border 属性设置为 0 来禁用边框(请参阅此处的文档, $边框参数)。
如果这不起作用,您可以完全禁用页码(以及边框)的渲染,或者您可以将边框设置为与实际背景相匹配的自定义颜色。
If the other solutions posted in this thread does not work, I solved in this way:
TL;DR
In Footer() function in Tcpdf class (tcpdf.php):
Replace this lines:
With this lines
Alternative way 1
Comment this lines in Footer() function in Tcpdf class (tcpdf.php):
In my file (version 6.3.1) they were placed at line 3524
This will disable the render of the page number in the footer but at least it removes the unwanted line.
Alternative way 2
If these methods does not work, search in the tcpdf.php file for this string:
You should find 3 occurrences, replace the 'color' property of the array with the value
[0,0,0]
(or the rgb color of your background), this should cause the line to turn white (or the color you set).I used this method to troubleshoot where the problem was by putting custom weird color and seeing which one was being rendered.
Explanation
The line is rendered because in the lines
The border property is set to 'T' (top border). You can disable the border by set the border property to 0 (see docs here, $border param).
If that doesn't work you can entirely disable the render of the page number (and thus the border), or you can set the border to a custom color that matches you actual background.
在 tcpdf 类的 Header() 函数中注释这一行:
Comment this line in Header() function of tcpdf Class :