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 7BA0C1728C for ; Fri, 27 Mar 2015 03:38:52 +0000 (UTC) Received: (qmail 16231 invoked by uid 500); 27 Mar 2015 03:38:39 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 16208 invoked by uid 500); 27 Mar 2015 03:38:39 -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 16197 invoked by uid 99); 27 Mar 2015 03:38:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Mar 2015 03:38:39 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of richard@ytivarg.com designates 206.123.106.155 as permitted sender) Received: from [206.123.106.155] (HELO skell.loowit.net) (206.123.106.155) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Mar 2015 03:38:12 +0000 Received: from [50.45.234.108] (helo=sydney.localnet) by skell.loowit.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84) (envelope-from ) id 1YbL60-0000gM-FO for users@pdfbox.apache.org; Thu, 26 Mar 2015 20:38:08 -0700 From: Richard Johnson To: users@pdfbox.apache.org Subject: External Tool? Date: Thu, 26 Mar 2015 20:38:01 -0700 Message-ID: <3253367.GqCVED553Z@sydney> User-Agent: KMail/4.14.1 (Linux/3.16.0-33-generic; KDE/4.14.1; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Score: -1.0 (-) X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, hits=-1.0 required=5.0 Hi, I'm using pdfbox to fill fields in pdf forms. The problem is that most forms we need to fill arrive "broken." Broken in the sense of we can load the file, we can find the field by name, but the first field on the page invariably gives us the nfamous exception: java.lang.NullPointerException at org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.calculateFontSize(PDAppearance.java:923) This is the sign that the form is "broken." Previously we used MasterPDFEditor to save the document, build the fields on it (all over again) and everything worked. Now, apparently that tool creates equally broken documents that we cannot fill with pdfbox. 1. Is there a better tool to use, one that would actually save usable files and not cost an arm and a leg? (For instance should I use pdfbox to do this work programmatically?) 2. Regardless of the answer to question 1, could I be doing something better in terms of opening and manipulating the file? (code sample below.) 3. Anything else that probably well known but I don't know enough to ask? ----- sample: PDDocument pdfDocument; PDAcroForm form; try { pdfDocument = PDDocument.load(templateLocation); form = pdfDocument.getDocumentCatalog().getAcroForm(); } catch (IOException ioe) { log.log(Level.SEVERE, "Unable to load a template: {0}\n{1}", new Object[]{templateLocation, ioe}); } PDField employerName = form.getField("Name_of_Employer"); employerName.setValue("TEST"); <<<------ NPE here -<<<<<<<<< -------- -- Richard Johnson --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org