IMO the PDFBox forum archives are hard to search. Have you already seen the examples at https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/ ?
I'll admit I didn't study your question in detail. It's 8pm here and I'm not yet done for the day. But I saw you ask for examples... Gary -----Original Message----- From: Dagnon, William <[email protected]> Sent: Tuesday, July 24, 2018 6:30 PM To: [email protected] Subject: PDFBox AcroForm: timeline? or how to make multiple copies of a page into one file? Hello all, newb here; I have a source PDF file, and I need to build a new file from it by selectively copying/not copying/duplicating pages, and filling out annotated fields in the new file. Eg. sometimes the new file will have 6 pages, sometimes it will have 10 pages. So far, my searches haven't turned up people asking questions about quite this situation: 1. one or more of the pages are forms, eg. have annotated fields and need to fill them in. 2. one of the form pages needs to get repeated in certain circumstances - mine is a table-of-inputs page with a header. May need zero, may need 1 or more copies filled out. I don't have a deep understanding of how the PDFBox operates, so I tried my simplistic version from the Javadocs and some Google-fu: pddoc.importPage(originalDoc.getPage(0)); cat = pddoc.getDocumentCatalog(); acroForm = cat.getAcroForm();// returns null field = acroForm.getField("name");// blows up with an NPE Meaning there is no PDAcroForm in the new PDDocument after I copy the first page, which has form fields. At least no cached version, according to my debugger. How do I get it to generate an appropriate AcroForm? Or do I need to wait for an AcroForm until all pages, or at least all field-containing pages, are in my pddoc before doing that? My secondary question addresses #2 above: how can I have 2 copies of the same page (form), and annotated elements, in one PDDocument? Does the 2nd copy of the PDPage need to rename all fields so all annotation names remain unique? Or can I operate on a copy of the PDPage and then import it into the final pddoc (assuming once the page has values, names won't interfere with existing names in the same PDDocument)? Websites, example code, deeper knowledge all appreciated! P.S. and thanks to daedtech.com for getting me started! CONFIDENTIALITY NOTICE: This e-mail, including any attachments, may contain confidential, privileged and/or proprietary information which is solely for the use of the intended recipient(s). Any review, use, disclosure, or retention by others is strictly prohibited. If you are not an intended recipient, please contact the sender and delete this e-mail, any attachments, and all copies. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

