pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Ternes <KTer...@thegeneral.com>
Subject NullPointerException from PDDocument
Date Fri, 07 Aug 2015 21:56:01 GMT

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


Mime
View raw message