TCPDF - 页脚的奇怪问题
在此处查看源代码:
http://www.savvissl.com/demo1/showcode.php< /a>
在此处查看脚本
http://www.savvissl.com/demo1/testPDF.php
问题是……除了最后一页之外,每页的页脚打印效果都很好。最后一页从来没有页脚。如果文档中只有一页,则根本不会打印页脚。
Check out the source code here:
http://www.savvissl.com/demo1/showcode.php
check out the script here
http://www.savvissl.com/demo1/testPDF.php
Here is the issue... the footer prints fine on every page except for the last page. The last page never has a footer. If there is only one page in the document the footer will not print at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我无法弄清楚,但我能够复制一个有效的同事示例。如果有人想要这里的源代码,那就是:
将这个新代码与我的旧代码进行比较,并不能洞察为什么它起作用......事实上,TCPDF 示例文件夹中的示例表现出相同的问题,但是如果您从他们的网站运行它,页脚显示正确。无论如何希望这对某人有帮助
OK I couldn't figure it out, but i was able to copy a co-workers example that worked. If anyone wants the source code here it is:
Comparing this new code to my old reveals no insight into why this works... in fact the example in the TCPDF examples folder exhibits the same issue, however if you run it from their website the footer is displayed correctly. Well anyway hope this helps someone
除了我刚刚通过浏览他们的文档了解到的内容之外,我对 TCPDF 一无所知。
看起来只有当您显式调用
AddPage()
时才会调用Footer()
,此时它会添加到上一页。其余时间我相信你必须自己调用它。还有整个
StartPage()/EndPage()
听起来像是AddPage()
的替代品。您可能想要:“起始页、页眉、绘制文本、页脚、结束页”。看起来
Write()
为您调用了AddPage()
,这就是为什么页眉和页脚出现在除最后一页之外的所有页面上。底线:在此示例中,只需在调用
Write()
后调用Footer()
即可。现实世界的例子几乎肯定会更复杂一些。I know nothing about TCPDF save what I just learned going through their docs.
It looks like
Footer()
is only called for you when you explicitly callAddPage()
, at which point it is added to the PREVIOUS PAGE. The rest of the time I believe you have to call it yourself.There's also this whole
StartPage()/EndPage()
thing that sounds like an alternative toAddPage()
.You might want to: "start page, header, draw text, footer, end page" instead. It looks like
Write()
callsAddPage()
for you, which is why the headers and footers on all-but-the-last-page are present.Bottom Line: Just call
Footer()
after you callWrite()
in this example. Real world examples will almost certainly be a bit more complex.