Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-1599

ConvertToImage gets ClassCastException with Checkboxes in PDFForm

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.8.1
    • 1.8.2
    • PDModel
    • Windows Vista, Java 1.6

    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

      Attachments

        1. Extraction.java
          3 kB
          Jens Vogt
        2. 00193_01_DE_A0002001_pdffields.pdf
          185 kB
          Jens Vogt

        Activity

          People

            lehmi Andreas Lehmkühler
            vogje01 Jens Vogt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: