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

NullPointerException in org.apache.pdfbox.pdmodel.graphics.PDShading.toString, when getDomain() returns null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.5.0
    • 1.6.0
    • PDModel
    • None
    • Windows 7, and Ubuntu 8.04
      PDFBox 1.5.0

    Description

      The problem is that the toString method is called on objects which may have been returned as null

      The suggested fix to this, in the attached patch is to check if null, then write an empty string

      String s = "Shading " + shadingname + "\n"
      + "\tShadingType: " + getShadingType() + "\n"
      + "\tColorSpace: " + sColorSpace + "\n"
      + "\tAntiAlias: " + getAntiAlias() + "\n"
      + "\tCoords: " + (getCoords() != null ? getCoords().toString() : "") + "\n"
      + "\tDomain: " + (getDomain() != null ? getDomain().toString() : "") + "\n"
      + "\tFunction: " + sFunction + "\n"
      + "\tExtend: " + (getExtend() != null ? getExtend().toString() : "") + "\n"
      + "\tRaw Value:\n" +

      <Error message as dumped to log>

      INFO [main] (PDFStreamEngine.java557) - unsupported/disabled operation: BDC
      INFO [main] (PDFStreamEngine.java557) - unsupported/disabled operation: BX
      WARN [main] (SHFill.java63) - java.lang.NullPointerException
      java.lang.NullPointerException
      at org.apache.pdfbox.pdmodel.graphics.PDShading.toString(PDShading.java:204)
      at org.apache.pdfbox.pdfviewer.PageDrawer.SHFill(PageDrawer.java:398)
      at org.apache.pdfbox.util.operator.pagedrawer.SHFill.process(SHFill.java:58)
      at org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:551)
      at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:274)
      at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:251)
      at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:225)
      at org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:107)
      at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:722)
      INFO [main] (PDFStreamEngine.java557) - unsupported/disabled operation: EX
      INFO [main] (PDFStreamEngine.java557) - unsupported/disabled operation: EMC

      </Error message as dumped to log>

      Attachments

        1. pdfbox_pdshading_tostring_npe.patch
          0.9 kB
          Craig Stires
        2. NoDomain_004k.pdf
          264 kB
          Craig Stires

        Activity

          People

            lehmi Andreas Lehmkühler
            craig_s Craig Stires
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: