[ https://issues.apache.org/jira/browse/PDFBOX-1276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ravikiran Mane updated PDFBOX-1276: ----------------------------------- Description: When trying to set value for a field in pdf, got following exception : java.lang.NullPointerException at org.apache.pdfbox.pdmodel.common.COSDictionaryMap.put(COSDictionaryMap.java:106) at org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.getFontAndUpdateResources(PDAppearance.java:440) at org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.setAppearanceValue(PDAppearance.java:268) at org.apache.pdfbox.pdmodel.interactive.form.PDVariableText.setValue(PDVariableText.java:131) at qs.common.GenerateReports.generateBidderDeclaration_OBS_05_105(GenerateReports.java:71) Hence after following suggestion from following link : http://mail-archives.apache.org/mod_mbox/pdfbox-dev/201108.mbox/%3cbe54ce7a716a7247b1d3bf9d9c187ced0843e...@som-teaqasmail1.som.w2k.state.me.us%3E i.e. intruduced a try-catch for retval = (PDFont)formResources.getFonts().get( fontName ); resolved the issue for me as well. Also, I had to add try-catch for following : printWriter.println(getTextPosition(boundingBox, pdFont, fontSize, tokens)); as getTextPosition() is throwing IOException as the pdFont is null. Creating this issue so that the bug is documented and would like to see the change in upcoming releases. Shall attach the jar file that contains the changes which resolved the issue. was: When trying to set value for a field in pdf, got following exception : java.lang.NullPointerException at org.apache.pdfbox.pdmodel.common.COSDictionaryMap.put(COSDictionaryMap.java:106) at org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.getFontAndUpdateResources(PDAppearance.java:440) at org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.setAppearanceValue(PDAppearance.java:268) at org.apache.pdfbox.pdmodel.interactive.form.PDVariableText.setValue(PDVariableText.java:131) at qs.common.GenerateReports.generateBidderDeclaration_OBS_05_105(GenerateReports.java:71) Hence after following suggestion from following link : http://mail-archives.apache.org/mod_mbox/pdfbox-dev/201108.mbox/%3cbe54ce7a716a7247b1d3bf9d9c187ced0843e...@som-teaqasmail1.som.w2k.state.me.us%3E i.e. intruduced a try-catch for retval = (PDFont)formResources.getFonts().get( fontName ); resolved the issue for me as well. Also, I had to add try-catch for following : printWriter.println(getTextPosition(boundingBox, pdFont, fontSize, tokens)); as getTextPosition() is throwing IOException as the font is null. Creating this issue so that the bug is documented and would like to see the change in upcoming releases. Shall attach the jar file that contains the changes which resolved the issue. > NullPointerException thrown at retval = (PDFont)formResources.getFonts().get( > fontName ); in org.apache.pdfbox.pdmodel.interactive.form.PDAppearance > ---------------------------------------------------------------------------------------------------------------------------------------------------- > > Key: PDFBOX-1276 > URL: https://issues.apache.org/jira/browse/PDFBOX-1276 > Project: PDFBox > Issue Type: Bug > Components: PDModel > Affects Versions: 1.6.0 > Environment: OS : Windows 7 > JVM : 1.7.0_02 [64-bit] > Reporter: Ravikiran Mane > Labels: patch > Fix For: 1.6.0 > > Attachments: pdfbox-app-1.6.0_changed.jar > > > When trying to set value for a field in pdf, got following exception : > java.lang.NullPointerException > at > org.apache.pdfbox.pdmodel.common.COSDictionaryMap.put(COSDictionaryMap.java:106) > at > org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.getFontAndUpdateResources(PDAppearance.java:440) > at > org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.setAppearanceValue(PDAppearance.java:268) > at > org.apache.pdfbox.pdmodel.interactive.form.PDVariableText.setValue(PDVariableText.java:131) > at > qs.common.GenerateReports.generateBidderDeclaration_OBS_05_105(GenerateReports.java:71) > Hence after following suggestion from following link : > http://mail-archives.apache.org/mod_mbox/pdfbox-dev/201108.mbox/%3cbe54ce7a716a7247b1d3bf9d9c187ced0843e...@som-teaqasmail1.som.w2k.state.me.us%3E > i.e. intruduced a try-catch for > retval = (PDFont)formResources.getFonts().get( fontName ); > resolved the issue for me as well. > Also, I had to add try-catch for following : > printWriter.println(getTextPosition(boundingBox, pdFont, fontSize, tokens)); > as getTextPosition() is throwing IOException as the pdFont is null. > Creating this issue so that the bug is documented and would like to see the > change in upcoming releases. > Shall attach the jar file that contains the changes which resolved the issue. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira