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 DB79C18AB5 for ; Tue, 11 Aug 2015 17:43:18 +0000 (UTC) Received: (qmail 78809 invoked by uid 500); 11 Aug 2015 17:43:09 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 78785 invoked by uid 500); 11 Aug 2015 17:43:09 -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 78774 invoked by uid 99); 11 Aug 2015 17:43:08 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Aug 2015 17:43:08 +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 6B4DD18193D for ; Tue, 11 Aug 2015 17:43:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.77 X-Spam-Level: * X-Spam-Status: No, score=1.77 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled 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 RYTcI9flHC8Q for ; Tue, 11 Aug 2015 17:43:07 +0000 (UTC) Received: from mailout09.t-online.de (mailout09.t-online.de [194.25.134.84]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 2A2A742B42 for ; Tue, 11 Aug 2015 17:43:07 +0000 (UTC) Received: from fwd21.aul.t-online.de (fwd21.aul.t-online.de [172.20.27.66]) by mailout09.t-online.de (Postfix) with SMTP id C4181F93D6 for ; Tue, 11 Aug 2015 19:42:59 +0200 (CEST) Received: from [192.168.2.102] (E1vzwwZ1ghRlhqk2t5pRCZDj46HOHTDN8afehQZBSgawPxeRQJIiW0YBgfsx14agMu@[217.231.154.185]) by fwd21.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1ZPDZf-38X07s0; Tue, 11 Aug 2015 19:42:55 +0200 Subject: Re: NullPointerException from PDDocument To: users@pdfbox.apache.org References: <55C52AEB.5060208@t-online.de> From: Tilman Hausherr Message-ID: <55CA344C.3090004@t-online.de> Date: Tue, 11 Aug 2015 19:43:40 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-ID: E1vzwwZ1ghRlhqk2t5pRCZDj46HOHTDN8afehQZBSgawPxeRQJIiW0YBgfsx14agMu X-TOI-MSGID: 2e197e94-56ed-49ec-8068-091ddb63f1ec Am 10.08.2015 um 16:25 schrieb Kevin Ternes: > Thanks Tilman, but I found the problem. It is not a malformed PDF. > The PDDocument was being prematurely closed in an earlier method. > > I still think it would be good if this method added a description message about the null trailer to the Exception. With an ordinary NullPointerException, we really have no idea what might have happened. We'd probably put some messages everywhere.... please accept that if you do illegal things, mayhem will follow :-) Tilman > > -----Original Message----- > From: Tilman Hausherr [mailto:THausherr@t-online.de] > Sent: Friday, August 07, 2015 5:02 PM > To: users@pdfbox.apache.org > Subject: Re: NullPointerException from PDDocument > > Can you upload the document somewhere? > > Tilman > > Am 07.08.2015 um 23:56 schrieb Kevin Ternes: >> I have a particular PDF that I have loaded that throws a NullPointerException from PDDocument.getDocumentCatalog(). >> From PDDocument: >> >> public PDDocumentCatalog getDocumentCatalog() { >> If (documentCatalog == null) >> { >> COSDictionary trailer = document.getTrailer(); >> COSBase dictionary = trailer.getDictionaryObject( COSName.ROOT ); >> if (dictionary instanceof COSDictionary) >> { >> documentCatalog = new PDDocumentCatalog(this, (COSDictionary) dictionary); >> } >> else >> { >> documentCatalog = new PDDocumentCatalog(this); >> } >> } >> return documentCatalog; >> } >> >> The document.getTrailer() returns NULL for this PDF and thus the NullPointerException from the next line. >> >> Is it possible that the PDF is malformed? >> I do not see where I might have cleared the document.trailer field. >> >> If any PDFBox developers are listening, would it be reasonable to put a check into the above code to deal with the NULL document.trailer? >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org >> For additional commands, e-mail: users-help@pdfbox.apache.org >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org > For additional commands, e-mail: users-help@pdfbox.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org > For additional commands, e-mail: users-help@pdfbox.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org