问题
How to get the current Page Number from PDF form using PDFBOX ?
Is there any way to get the particular fields page number? For example, if a text box named First name
is present on 4 page of a PDF form is it possible to retrieve current Page number as 4?
Any insight into a possible solution?
Thanks
回答1:
I am usually filling the page number information on every new page during the pdf build. This means that I know the page number of the edited page which is currently the last page.
private void addPageNumber(int page, PDPageContentStream content) throws Exception {
content.beginText();
String pageNumber = page + "";
// TODO: move to the needed text position
content.drawString(pageNumber);
content.endText();
}
I call this method with the current number of pages as a parameter:
addPageNumber(_document.getNumberOfPages(), content);
来源:https://stackoverflow.com/questions/14831695/how-to-get-the-current-page-number-from-pdf-form-using-pdfbox