Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9D7481801A for ; Wed, 26 Aug 2015 23:35:54 +0000 (UTC) Received: (qmail 68500 invoked by uid 500); 26 Aug 2015 23:35:54 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 68481 invoked by uid 500); 26 Aug 2015 23:35:54 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 68211 invoked by uid 99); 26 Aug 2015 23:35:53 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Aug 2015 23:35:53 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 7404F181BC3 for ; Wed, 26 Aug 2015 23:35:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.001 X-Spam-Level: *** X-Spam-Status: No, score=3.001 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id vWRoMwpkTGHC for ; Wed, 26 Aug 2015 23:35:45 +0000 (UTC) Received: from mail-yk0-f171.google.com (mail-yk0-f171.google.com [209.85.160.171]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id D2E1A42BF6 for ; Wed, 26 Aug 2015 23:35:44 +0000 (UTC) Received: by ykfw73 with SMTP id w73so3046971ykf.3 for ; Wed, 26 Aug 2015 16:35:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=gfuQbZlSLEqy9PRq1dV9c3X3PPhiSxfG0FTJPiifPrc=; b=toPn7mPWmpv43fKoUDLNUuwS63YV3i6u8L1JrIuOs+l5u3JqTo67dMRuikuWTVR6sZ Sb9LvLEXcL5gBl1aPalX9YeqRGO+b5t1wcLH7KXmJN0hdkc28xwpbaJm3OFtHDgGr3wX LxmLvxVtY9rA1zTT6W7mGNDA35Awfh8H7fO57VTg5tLBCzp1mJP9nRkDdbnfkB00VufQ cmlhECVF8z4VM0KuvDFMoLIYfkEl8UO33B9aG5u7FARJdW/UlGC9FDZsZMap8Itf2PJC 5/wd6+WKEX9vJZSGDMzcpE9O0M34IeAsPFwbU/rXLa+kVWAGpZjT/0cdbHJzpa8w20Yz P2dg== MIME-Version: 1.0 X-Received: by 10.170.96.86 with SMTP id n83mr1013652yka.45.1440632144558; Wed, 26 Aug 2015 16:35:44 -0700 (PDT) Sender: tolenmiller@gmail.com Received: by 10.129.77.194 with HTTP; Wed, 26 Aug 2015 16:35:44 -0700 (PDT) In-Reply-To: References: <8C172222-9B83-4689-B3EE-469286647334@fileaffairs.de> Date: Wed, 26 Aug 2015 16:35:44 -0700 X-Google-Sender-Auth: AgJYJfOAPAMzNsIfTyvcz7weCwE Message-ID: Subject: Re: Cannot load pre existing PDF to access fields From: Tolen Miller To: users@pdfbox.apache.org Content-Type: multipart/alternative; boundary=001a113a60a43a85a6051e3f4f27 --001a113a60a43a85a6051e3f4f27 Content-Type: text/plain; charset=UTF-8 forgot stack trace... *Exception in thread "AgentThread: JavaAgent" java.security.AccessControlException: Access denied (java.lang.RuntimePermission createSecurityManager)* * 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.checkRuntimePermission(AppletSecurity.java:1311)* * at COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1611)* * at COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1464)* * at java.lang.SecurityManager.(SecurityManager.java:294)* * at JavaAgent$MySecurityManager.(JavaAgent.java:159)* * at JavaAgent$MySecurityManager.(JavaAgent.java:159)* * at JavaAgent.NotesMain(JavaAgent.java:36)* * at lotus.domino.AgentBase.runNotes(Unknown Source)* * at lotus.domino.NotesThread.run(Unknown Source)* On Wed, Aug 26, 2015 at 4:35 PM, Tolen Miller wrote: > Well, I'm not sure that will work either: > > On Wed, Aug 26, 2015 at 4:17 PM, Roberto Nibali wrote: > >> Hi >> >> You use Notes/Domino, which is quiet a challenge when it comes to >> application security. The Java API of Notes/Domino contains two different >> SecurityManagers - one for agents and one for servlets. The >> SecurityManager >> for agents is COM.ibm.JEmpower.applet.AppletSecurity and the >> SecurityManager for servlers is lotus.notes.AgentSecurityManager. Both >> inherit directly from java.lang.SecurityManager. Make sure you have the >> appropriate settings and talk to the administrator of this node. Last but >> not least, I suppose you have a support contract with IBM. >> >> If you can fiddle around with the JVM you'd like to invoke, add your own >> grant policy file: -Djava.security.policy=applet.policy >> >> However, I doubt Lotus will let you do this, and most probably you'll hit >> a >> classloader issue. With some luck you could hijack the SecurityManager as >> follows: >> >> private class MySecurityManager extends SecurityManager { >> @Override >> public void checkPermission(Permission perm) { >> return; >> }} >> >> >> At the start of your Applet, you do the following: >> >> SecurityManager sm = new >> MySecurityManager();System.setSecurityManager(sm); >> >> >> Good luck >> >> Roberto >> >> On Thu, Aug 27, 2015 at 12:08 AM, Tolen Miller >> wrote: >> >> > 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.(PDType1CFont.java:102)* >> > * at >> > org.apache.pdfbox.pdmodel.font.PDType1Font.(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 >> wrote: >> > >> > > Hi >> > > >> > > On Wed, Aug 26, 2015 at 9:27 AM, Maruan Sahyoun < >> sahyoun@fileaffairs.de> >> > > wrote: >> > > >> > > > Hi, >> > > > >> > > > > Am 26.08.2015 um 06:00 schrieb Tolen Miller > >: >> > > > > >> > > > > 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 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 >> > > >> > >> > > --001a113a60a43a85a6051e3f4f27--