Neither of the streamresources not formresources are null, yet they don't contain the font information needed.
retval = (PDFont)formResources.getFonts().get( fontName ); is still null causing the exception. Perhaps this should be in a try catch block? If I force it to bypass the entire if, as if formResources were null, it seems to work ok. Exception in thread "main" java.lang.NullPointerException at org.apache.pdfbox.pdmodel.common.COSDictionaryMap.put(COSDictionaryMap.j ava:106) at org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.getFontAndUpdate Resources(PDAppearance.java:440) at org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.setAppearanceVal ue(PDAppearance.java:268) at org.apache.pdfbox.pdmodel.interactive.form.PDVariableText.setValue(PDVar iableText.java:131) at gov.maine.revenue.ifileviewer.IfileViewer.setField(IfileViewer.java:65) at gov.maine.revenue.ifileviewer.IfileViewer.main(IfileViewer.java:37) Confidentiality Notice The information contained in this message may be privileged and confidential, and its improper disclosure subject to legal penalties. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you, Maine Revenue Services.