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

ClassCastException in PDExtendedGraphicsState

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.11
    • 2.0.12, 3.0.0 PDFBox
    • Parsing
    • None

    Description

      The method PDExtendedGraphicsState.getFloatItem contains a non checked cast to COSNumber for a dictionary object. In a specific journal PDF document I get the following exception:

      at org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState.getFloatItem(PDExtendedGraphicsState.java:591)
              at org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState.getStrokingAlphaConstant(PDExtendedGraphicsState.java:482)
              at org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState.copyIntoGraphicsState(PDExtendedGraphicsState.java:130)
              at org.apache.pdfbox.contentstream.operator.state.SetGraphicsStateParameters.process(SetGraphicsStateParameters.java:61)
              at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:848)

      because the PDF contains

      /A4 <<
      /CA (1.0)
      /Type /ExtGState
      /ca (1.0)
      >>
      

      where "(1.0)" is clearly wrong and should be "1.0".

      As this seems to be a more seldom error I would suggest to check dictionary object type before casting and returning "null" for wrong type (as it is done e.g. in PDExtendedGraphicsState.getFontSetting.

      Attachments

        Activity

          People

            tboehme Timo Boehme
            tboehme Timo Boehme
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: