开发者

Java iText Page X of Y

开发者 https://www.devze.com 2023-01-19 23:33 出处:网络
I’m using iText to generate a PDF document in my Java EE application. Coding for the PDF file is reside in a JSP.

I’m using iText to generate a PDF document in my Java EE application. Coding for the PDF file is reside in a JSP.

I want to achieve the following page formatting in my each page footer,


REF: XXXXXXX           &nb开发者_高级运维sp;                                               Page X of Y


How can I get Page X of Y


There is a sample here: http://faq.javaranch.com/java/ItextExample

In a nutshell, you create a Header/Footer class with an onPageEnd event to add a header or footer.

Addendum from my comment below after reading the other question from OP: PdfWriter.getCurrentPageNumber only returns the current page number. You can't get the total while writing the document because, obviously, you don't know the total yet. The way to do that is explained here: How to add the total page number on each page or in Ashis' answer here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号