java.io.IOException: For input string: "2152829241"
---------------------------------------------------

                 Key: PDFBOX-1225
                 URL: https://issues.apache.org/jira/browse/PDFBOX-1225
             Project: PDFBox
          Issue Type: Bug
          Components: PDFReader
    Affects Versions: 1.6.0
         Environment: Windows 7 / Windows XP
            Reporter: Anca Zapuc


I had a pdf of 6 pages, size of 2,40 GB.
I can open the PDF with AcrobatReader 9, but I cannot open with FoxitReader. 
(pdf corrupted)

The code I am using to count pages is the following:
            //create a temporary file needed by the PDFBox when dealing with 
PDFs really really large
            temp = new File("e:/temp.tmp");
            //using random access file needed for PDF really large
             rand = new RandomAccessFile(temp,"rw");
            doc = PDDocument.load(file,rand);
            nr = doc.getNumberOfPages();
        
I receive the following exception:
java.io.IOException: For input string: "2152829241"
        at 
org.apache.pdfbox.pdfparser.PDFParser.parseXrefTable(PDFParser.java:730)
        at org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:452)
        at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:184)
        at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1069)
        at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1022)
        at PDFBoxExample.getHugeNrOfFiles(PDFBoxExample.java:36)
        at PDFBoxExample.main(PDFBoxExample.java:257)

After searching in your code , I found the cause of the exception is 
NumberFormatException , due to 2152829241 =>
Integer.parseInt(2152829241) crashes , because 2152829241  > Integer.MAX_VALUE

I have made several changes to the source code  :
XRefTrailerResolver
COSDocument
PDFParser
COSWriter
BaseParser
XRefTrailerResolver

changing from int to long  => code worked
Is it possible for you to change the code accordingly or I can send you the 
classes.



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to