Hello again, I was able to get the PrintFields example working, so thanks for that. I then applied what I learned to my situation and everything seemed to be going well, but now I have run into a roadblock: *java.lang.RuntimeException: java.security.AccessControlException: Access denied (java.lang.reflect.ReflectPermission suppressAccessChecks)* * at org.apache.pdfbox.pdmodel.font.PDType1CFont.load(PDType1CFont.java:411)* * at org.apache.pdfbox.pdmodel.font.PDType1CFont.<init>(PDType1CFont.java:102)* * at org.apache.pdfbox.pdmodel.font.PDType1Font.<init>(PDType1Font.java:162)* * at org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:92)* * at org.apache.pdfbox.pdmodel.PDResources.getFonts(PDResources.java:213)* * at org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.getFontAndUpdateResources(PDAppearance.java:820)* * at org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.setAppearanceValue(PDAppearance.java:316)* * at org.apache.pdfbox.pdmodel.interactive.form.PDVariableText.setValue(PDVariableText.java:131)* * at JavaAgent.NotesMain(JavaAgent.java:69)* * at lotus.domino.AgentBase.runNotes(Unknown Source)* * at lotus.domino.NotesThread.run(Unknown Source)* *Caused by: java.security.AccessControlException: Access denied (java.lang.reflect.ReflectPermission suppressAccessChecks)* * at java.security.AccessController.throwACE(AccessController.java:100)* * at java.security.AccessController.checkPermission(AccessController.java:174)* * at java.lang.SecurityManager.checkPermission(SecurityManager.java:544)* * at COM.ibm.JEmpower.applet.AppletSecurity.superDotCheckPermission(AppletSecurity.java:1449)* * at COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1617)* * at COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1464)* * at java.lang.reflect.AccessibleObject.setAccessible(AccessibleObject.java:118)* * at org.apache.pdfbox.pdmodel.font.PDType1CFont.load(PDType1CFont.java:406)* * ... 10 more*
This occurs just as I am calling PDField.setValue() and assigning a value. I checked the java.policy file and the location where the PDFBox JAR is stored has "AllPermission". I also ensured that my PDF has no security. Any thoughts on what else to look for? On Wed, Aug 26, 2015 at 2:15 AM, Roberto Nibali <[email protected]> wrote: > Hi > > On Wed, Aug 26, 2015 at 9:27 AM, Maruan Sahyoun <[email protected]> > wrote: > > > Hi, > > > > > Am 26.08.2015 um 06:00 schrieb Tolen Miller <[email protected]>: > > > > > > I uploaded my PDF again, if someone wants to see if they can get all of > > the > > > fields to return: http://1drv.ms/1PRKZsI > > > > > > After looking at the sample provided by Maruan, I noticed that I was > not > > > passing in a File object, when calling the PDDocument.load() method. > > Doing > > > so, I now get the same result from Maruan's code (in eclipse). > > > > > > Now I am unsure how to get *all* of the fields from the PDAcroForm. I > am > > > trying to get a collection of the fields, so I can loop through them. > > When > > > I add this code: > > > > > > List<PDField> pdfFields = form.getFields(); > > > for (PDField field : pdfFields) { > > > System.out.println("PDF Field Full Name: ".concat(field > > > .getFullyQualifiedName())); > > > } > > > > > > > as there is only one 'root' field you have to get it's kids and process > > the field tree down. Take a look at > > org.apache.pdfbox.examples.fdf.PrintFields of how to do that. > > > > > Having spent the last two months intensively with form fields, here is my > current code to dump the fields: > > private void executeDumpFields(String srcDocName) throws IOException { > PDDocument srcDoc = null; > try { > srcDoc = PDDocument.load(new File(srcDocName)); > > srcDoc.getDocumentCatalog().getAcroForm().getFields().forEach(this::dumpField); > srcDoc.close(); > } catch (Exception e) { > logerr(e.getMessage()); > } finally { > if (srcDoc != null) { > srcDoc.close(); > } > } > } > > private void dumpField(PDField srcField) { > if (srcField instanceof PDNonTerminalField) { > ((PDNonTerminalField) > srcField).getChildren().forEach(this::dumpField); > } else if (!(srcField instanceof PDSignatureField)) { > System.out.printf("fqName=%s type=%s%n", > srcField.getFullyQualifiedName(), > srcField.getClass().getSimpleName()); > } > } > > Maybe you can use some of it. Just call the executeDumpFields(...) with the > appropriate PDF name as a string and go from there. Not understanding the > PDF standard and how the dictionary trees are built up inside PDF, I had a > hard time initially understanding why I need to kind of recursively to > through the PDField entries. > > Cheers > Roberto >

