According to the PDF Reference (ISO 32000), BaseFont is a required
field.  So where did this PDF come from?

It's possible that the font's FondeDescriptor has a /FontName entry
(also required, and required to match BaseName).  I suspect Adobe has
bullet-proofed their applications to the point where either will
suffice.  Heck, they could even query the font program directly if it
was available.

So while I wouldn't go so far as to call it a bug in iText, we certainly
could be more durable in the face of malformed PDFs.  At the very least,
we could throw something more meaningful than an NPE.

Ben?  Do you have Acrobat 9 Pro?  It has a PDF syntax check that would
(hopefully) help you reach this sort of conclusion much faster, and
wouldn't require you to fold/spindle/mutilate your PDF for public
consumption.

--Mark Storer
  Senior Software Engineer
  Cardiff.com
 
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
 

> -----Original Message-----
> From: Ben Short [mailto:b...@benshort.co.uk]
> Sent: Wednesday, June 16, 2010 3:12 PM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] NPE while Extracting text
> 
> On Mark's advice I downloaded the source code from the 5.0.2 branch
> and dug a little deeper...
> 
> The NPE is thrown on the following line of the DocumentFont
constructor.
> 
> fontName =
> PdfName.decodeName(font.getAsName(PdfName.BASEFONT).toString());
> 
> It turns out that font.getAsName(PdfName.BASEFONT) returns null.
> 
> font, which is a PdfDictionary, has the following values in its hash
> map...
> 
> {/FontBBox=[-2, -9, 38, 40], /LastChar=121, /FontMatrix=[0.240000, 0,
> 0, 0.240000, 0, 0], /Type=/Font, /Resources=Dictionary, /CharProcs=134
> 0 R, /Encoding=72 0 R, /Subtype=/Type3, /Name=/C0HN2000T1X005000,
> /Widths=135 0 R, /FirstChar=32}
> 
> You'll notice that there is no key for /BaseFont.
> 
> I'm not sure I can post the whole pdf to a public news group... I will
> see if I can cut it down to a page or so of none sensitive data first.
> 
> Ben
> 

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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