Hi,

I have found that BaseFonts.getDocumentFonts throws a null pointer exception 
with some PDF files. I have traced the exception to the end of the 
recourseFonts method, in particular line 1449 of the BaseFonts source file:

1446       PdfDictionary xobj = resources.getAsDict(PdfName.XOBJECT);
1447        if (xobj != null) {
1448            for (Object element : xobj.getKeys()) {
1449                recourseFonts(xobj.getAsDict((PdfName)element), hits, 
fonts, level);
1450            }
1451        }

It seems that xobj.getAsDict((PdfName)element returns a null value in some 
cases. I have changed the above code as follows:

                PdfDictionary xobj = resources.getAsDict(PdfName.XOBJECT);
                if (xobj != null) {
                    for (Object element : xobj.getKeys()) {
                        PdfDictionary dict = xobj.getAsDict((PdfName)element);
                        if (dict != null) recourseFonts(dict, hits, fonts, 
level);
                    }
                }

and it works. Anybody has had the same problem? 

-- Juan




------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to