将表格继续到下一个 PDF 页,并打印中间的文本
我不知道我想做的事情是否可能,而且对于一些非常微不足道的事情来说,这可能是太多的工作。我有一个创建 PDF 的 servlet。我正在使用 iText 写入创建的 pdf,在我的 pdf 中,我有一个可以更改文档大小的动态表。每当需要转到下一页时,我想在文档底部打印“下一页继续”。问题是我永远不会知道文档中分页符发生在哪里。
如果可能的话,我非常乐意为此添加代码。另外,如果不清楚,请随时提问,谢谢。
编辑:可能是在自言自语,但我认为这是可能的唯一方法是如果有一种方法可以意识到刚刚创建了一个新页面。
I dont know if what I am trying to do is even possible, and it might be too much work for something very insignificant. I have a servlet that creates a PDF. I am using iText to write to the created pdf, in my pdf I have a dynamic table that can change the size of the document. I would like to print "Continued on next page" at the bottom of the document whenever it needs to go to the next page. The problem is I will never know where the page break occurs in my document.
I am more than happy to add code to this, if this is possible. Also, if this isnt clear, feel free to ask questions, thanks.
EDIT: Probably talking to myself, but The only way that I think this is possible is if there is a method that realizes that a new page has just been created.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试在 pdf 生成器类中应用此代码段:
仅供参考,有一堆 iText 示例,在您的情况下搜索页脚。希望这有帮助。
You can try to apply this snippet in your pdf generator class:
FYI, there are bunch of iText examples, in your case search for footer. Hope this helps.
您也许可以使用 setSkipLastFooter(boolean)。这样,它将打印表格的页脚行,该行在除最后一页之外的每一页上都有连续的文本。您需要确保在表格上设置FooterRows。
您还可以使用 PdfPageEventHelper,它允许您拦截各种页面事件,包括结束页面事件。在 onEndPage 方法内,您可以将“下一页继续”文本添加到文档中。
You can probably make use of setSkipLastFooter(boolean). This way, it will print the footer row of your table that has the continued text on every page except the last. You will need to be sure to setFooterRows on the table.
You could also use PdfPageEventHelper, which allows you to intercept various page events including end page event. Inside the onEndPage method you can add the "Continued On Next Page" text to the document.