Details
Description
When creating an image from a PDF Form we get an CastCastException in:
Exception in thread "main" java.lang.ClassCastException: org.apache.pdfbox.cos.COSName cannot be cast to org.apache.pdfbox.cos.COSStream
at org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary.getNormalAppearance(PDAppearanceDictionary.java:103)
at org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:140)
at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:781)
at org.apache.pdfbox.examples.util.Extraction$BarcodeLocator.getBarcode(Extraction.java:418)
at org.apache.pdfbox.examples.util.Extraction$BarcodeLocator.access$000(Extraction.java:379)
at org.apache.pdfbox.examples.util.Extraction.<init>(Extraction.java:103)
at org.apache.pdfbox.examples.util.Extraction.main(Extraction.java:138)
An further analysis shows that it seems to be related to checkboxes on the PDF Form. I fixed it temporarily using:
try
{ COSStream as = (COSStream)map.getDictionaryObject( asName ); actuals.put( asName.getName(), new PDAppearanceStream( as ) ); }catch (ClassCastException ex)
{ System.err.println("Exception name: " + asName.getName()); }in PDAppearanceDictionary.java.
Best regards
Jens