pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ske...@gmail.com
Subject ClassCastException at PDFParser:667 (PDFBox 1.8.10)
Date Fri, 24 Jul 2015 14:46:06 GMT
I'm using PDFMergerUtility to merge a number of PDF input streams and write
them to an HTTP response output stream.  One of the PDFs is failing at line
667 in PDFParser:

    final COSName objectType = (COSName)strmObj.getItem( COSName.TYPE );

The result of getItem(COSName.TYPE) is a COSString (value "Metadata") and
not a COSName.

I have patched this locally by changing the code to the following:

    COSBase baseObject = (COSBase)strmObj.getItem( COSName.TYPE );

    COSName objectType = null;

    if (baseObject instanceof COSString) {

        String baseObjectValue = ((COSString)baseObject).getString();

        objectType = COSName.getPDFName(baseObjectValue);

    }

    else

    {

        objectType = (COSName)baseObject;

    }
With this change, I am able to merge my PDF input streams without error.

Does this seem like an acceptable change (that should be submitted as a
patch) or am I missing something?  The PDFs being merged are viewable by
Chrome's internal PDF viewer as well as OSX Preview, Adobe Reader and
Bluebeam Vu/Revu.

Thanks!

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message