问题描述
我正在使用Java中的iText创建一些PDF报告。根据要求,我应该做的是以 page_number / page_numbers_in_total 的格式对页面进行编号。
I am creating some PDF reports using iText in Java. According to the requirements, what I should do is to number pages in the format of page_number/page_numbers_in_total.
但是,内存操作会给我的项目带来负担。因此,我不想再次浏览所有页面以便对它们进行编号。有没有办法实现呢?
However, memory operations burden my project. Hence, I don't want to go over all the pages again in order to number them. Is there any method to achieve that?
推荐答案
看看,它设置了一个类似的标题(Y页面X):
Have a look at this example, which sets a similar header ("Page X of Y"):
你会看到 onEndPage
方法打印Page X of和 onCloseDocument
方法通过PdfTemplate在所有页面上设置Y。
You'll see that the onEndPage
method prints the "Page X of ", and the onCloseDocument
method sets the "Y" on all the pages through a PdfTemplate.
这篇关于PDF中的PDF页面编号& iText的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!