You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Dawn Zoƫ Raison <da...@digitorial.co.uk> on 2011/09/25 14:59:32 UTC

PDFBox "null pointer" issue...

Hi Folks,

I have an issue with a number of PDF files (created using ABBYY pro 11) 
that have the 'Type' attribute missing in the Font dictionary. The PDF 
reference (v1.7) indicates that this is a mandatory field that must be 
set to 'Font' however in these files it is just not present - I have 
gone back to the software provider to enquire about a fix.

In the meantime, whenever PDFontFactory.createFont(COSDictionary) 
attempts to instantiate a font it falls over as it doesn't check type 
for null before it tries to compare it.
In a local copy I have changed the test (as below) and the files now 
process correctly.

         COSName type = (COSName)dic.getDictionaryObject( COSName.TYPE );
         if( type != null && !type.equals( COSName.FONT ) )
         {
             throw new IOException( "Cannot create font if /Type is not 
/Font.  Actual=" +type );
         }

Is it worth putting a more meaningful check into the next PDFBox to 
either report an error or cope (as I have done here), rather than 
falling over?

As an aside, when I attempted to build PDFBox 1.6.0 from the source zip 
it was missing the resource file glyphlist.txt.

-- 

Rgds.
*Dawn Raison*