I have a pdf with acroform. I use iText to open this pdf file and fill in the form fields with some data. Sometimes I need to create more pages than the original pdf. To do this, I create one page and replace the existing page with this code:
OutputStream output = new FileOutputStream("C:\\newFile.pdf"); PdfStamper stamper = PdfHelper.openPdfStamper("C:\\template.pdf", output); stamper.insertPage(NEW_PAGE_NUMBER, new Rectangle(0,0)); stamper.replacePage(stamper.getReader(), EXISTING_PAGE_NUMBER, NEW_PAGE_NUMBER);
By doing this, the fields on the existing page are not copied to the new page.
Is this a good way to add a new page? (the new page must be equal to the existing one)
How to copy form fields to a new page? How to change the name of a new form field so that there are no duplicate fields?
EDIT: There is a table on the page I want to copy. But this table has only ten rows. If the user enters more than ten elements, I want to fill in the entire table and create a new page to fill with other elements.
Now I am making several copies of this page to avoid this overflow. But I do not think this is an elegant solution, and it does not work for very large inputs.
source share