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

COSNumber NumberFormatException for large number

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.11, 2.0.0
    • Fix Version/s: 1.8.12, 2.0.0
    • Component/s: Parsing
    • Labels:
      None

      Description

      When trying to load a pdf containing the following:
      <</Type/Pattern/TilingType 2/Resources 52 0 R/XStep 32767/BBox[-89884656743115785407263711865852178399035283762922498299458738401578630390014269380294779316383439085770229476757191232117160663444732091384233773351768758493024955288275641038122745045194664472037934254227566971152291618451611474082904279666061674137398913102072361584369088590459649940625202013092062429184 -89884656743115785407263711865852178399035283762922498299458738401578630390014269380294779316383439085770229476757191232117160663444732091384233773351768758493024955288275641038122745045194664472037934254227566971152291618451611474082904279666061674137398913102072361584369088590459649940625202013092062429184 89884656743115785407263711865852178399035283762922498299458738401578630390014269380294779316383439085770229476757191232117160663444732091384233773351768758493024955288275641038122745045194664472037934254227566971152291618451611474082904279666061674137398913102072361584369088590459649940625202013092062429184 89884656743115785407263711865852178399035283762922498299458738401578630390014269380294779316383439085770229476757191232117160663444732091384233773351768758493024955288275641038122745045194664472037934254227566971152291618451611474082904279666061674137398913102072361584369088590459649940625202013092062429184]/Matrix[0.61 0 0 -0.601 0 0.319]/YStep 32767/Length 28563/Filter/FlateDecode/PatternType 1/PaintType 1>>stream
      I get a NumberFormatException in
      at org.apache.pdfbox.cos.COSNumber.get(COSNumber.java:109)
      at org.apache.pdfbox.pdfparser.BaseParser.parseDirObject(BaseParser.java:929)
      at org.apache.pdfbox.pdfparser.BaseParser.parseCOSArray(BaseParser.java:648)
      at org.apache.pdfbox.pdfparser.BaseParser.parseDirObject(BaseParser.java:856)
      at org.apache.pdfbox.pdfparser.BaseParser.parseCOSDictionaryValue(BaseParser.java:148)
      at org.apache.pdfbox.pdfparser.BaseParser.parseCOSDictionaryNameValuePair(BaseParser.java:272)
      at org.apache.pdfbox.pdfparser.BaseParser.parseCOSDictionary(BaseParser.java:205)
      at org.apache.pdfbox.pdfparser.BaseParser.parseDirObject(BaseParser.java:844)
      at org.apache.pdfbox.pdfparser.COSParser.parseFileObject(COSParser.java:751)
      at org.apache.pdfbox.pdfparser.COSParser.parseObjectDynamically(COSParser.java:720)
      at org.apache.pdfbox.pdfparser.COSParser.parseObjectDynamically(COSParser.java:651)
      at org.apache.pdfbox.pdfparser.COSParser.parseDictObjects(COSParser.java:612)
      at org.apache.pdfbox.pdfparser.PDFParser.initialParse(PDFParser.java:203)
      at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:230)
      at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:972)
      at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:876)

      Adobe Reader and Chrome consider it a valid pdf and it load it.

      I cannot share the PDF because of copyright issues, but I reproduced it with :"pdfbox\src\test\resources\input\rendering\source.pdf" from pdfbox-2.0.0-RC1-src.zip.
      Changing the value 0 from "/BBox [0 0 2480 3508]" to -89884656743115785407263711865852178399035283762922498299458738401578630390014269380294779316383439085770229476757191232117160663444732091384233773351768758493024955288275641038122745045194664472037934254227566971152291618451611474082904279666061674137398913102072361584369088590459649940625202013092062429184
      throws the exception.

      Using "new COSFloat(number)" works in this case.

        Attachments

        1. source.pdf
          226 kB
          Andrei T
        2. PDFBOX_3116.patch
          11 kB
          Maciej Woźniak

          Activity

            People

            • Assignee:
              lehmi Andreas Lehmkühler
              Reporter:
              andrei.toma Andrei T
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: