NullPointerException with embedded TTF

  • Aleksandr Smyshliaev


    While filling a PDF form, i get this exception:

    Exception in thread "main" java.lang.NullPointerException
            at java.util.Hashtable.put(
            at org.pdfclown.documents.contents.fonts.SimpleFont.onLoad(
            at org.pdfclown.documents.contents.fonts.Font.load(
            at org.pdfclown.documents.contents.fonts.Font.<init>(
            at org.pdfclown.documents.contents.fonts.SimpleFont.<init>(
            at org.pdfclown.documents.contents.fonts.TrueTypeFont.<init>(
            at org.pdfclown.documents.contents.fonts.Font.wrap(
            at org.pdfclown.documents.contents.FontResources.wrap(
            at org.pdfclown.documents.contents.FontResources.wrap(
            at org.pdfclown.documents.contents.ResourceItems.get(
            at org.pdfclown.documents.interaction.forms.TextField.refreshAppearance(
            at org.pdfclown.documents.interaction.forms.TextField.setValue(
            at FillForm.fillForm(
            at FillForm.main(

    The error comes from the very first widths entry, i.e. charCode is FirstChar (zero).  Code lookup gives 65533, which is not in the glyphIndexes table.  Maximum code present in glyphIndexes is 65532.

    Is there anything I can do to avoid this error?  The PDF file with the form that I have to fill comes from outside my company.

  • Aleksandr Smyshliaev

    Update: there would be the same failure for all characters in range 0-31 and for character 152.

  • Anonymous - 2012-06-28

    Am also having the same issue with SimpleFont where I have multiple codes not in the glyphIndexes Map.  I am trying to render a PDF to an image.

  • zievereir

    zievereir - 2012-10-10

    I also stumbled on this NullPointerException while parsing PDFs. I'm using PDF Clown to parse PDFs and to highlight text and my highlighting process always failed when this Exception occured. I got around it by editing the PDF Clown sources, I added a null check on glyphIndexes.get(code) in order to avoid having my highlighting process being disrupted.
    if(code != null && glyphIndexes.get(code) != null)

    I'm mainly just reading through PDF's so I'm not sure if this happens to have an impact on writing a PDF, but for me at least this does the trick.

    Thanks for the great library btw!


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks