iText copy form fields

Is there a way in iText to copy just the PDF acroform fields from one PDF document to another PDF document? I have the code to copy the entire PDF, but I would like to be able to overlay all my fields to a new/updated PDF document.

Answer

public void replaceBackground(String newBackground, String CurrentForm, String newFile) throws Exception
        {
            PdfReader reader = new PdfReader(newBackground);
            PdfReader reader2 = new PdfReader(CurrentForm);
            PdfStamper stamp = new PdfStamper(reader2, new FileOutputStream(newFile));
            stamp.replacePage(reader, 1, 1);
            stamp.close();
        }

Leave a Reply

Your email address will not be published. Required fields are marked *