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

NumberFormatException when loading large PDF file

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.2, 2.0.3, 3.0.0 PDFBox
    • Fix Version/s: 2.0.3, 3.0.0 PDFBox
    • Component/s: Parsing, PDModel
    • Labels:
      None
    • Environment:
      Win 10 Pro, 16GB RAM

      Description

      If you trying to load very large PDF file (over 2GB), you get java.io.IOException: java.lang.NumberFormatException: For input string: "2313730984".

      It fails in COSParser.java in parseXrefTable(long startByteOffset). On the line 2006, if Integer.parseInt(splitString[1]) reads number which is bigger than maximum int.

      //////
      java.io.IOException: java.lang.NumberFormatException: For input string: "2313730984"
      at org.apache.pdfbox.pdfparser.COSParser.parseXrefTable(COSParser.java:2012)
      at org.apache.pdfbox.pdfparser.COSParser.parseXref(COSParser.java:223)
      at org.apache.pdfbox.pdfparser.PDFParser.initialParse(PDFParser.java:192)
      at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:249)
      at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:840)
      at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:765)
      at Test.main(Test.java:17)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
      Caused by: java.lang.NumberFormatException: For input string: "2313730984"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.lang.Integer.parseInt(Integer.java:583)
      at java.lang.Integer.parseInt(Integer.java:615)
      at org.apache.pdfbox.pdfparser.COSParser.parseXrefTable(COSParser.java:2005)
      ... 11 more

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tilman Tilman Hausherr
                Reporter:
                p.fol Pavel Fol
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: