PDF中的PDF页面编号& iText的 [英] PDF Page Numbering in Java & iText

查看:171
本文介绍了PDF中的PDF页面编号& iText的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆