[ 
https://issues.apache.org/jira/browse/PDFBOX-2920?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15399569#comment-15399569
 ] 

Tilman Hausherr edited comment on PDFBOX-2920 at 7/29/16 4:02 PM:
------------------------------------------------------------------

Another thought about this: I possibly didn't notice last year that 
RandomAccessBuffer is for buffers in memory only.

[~beta-brad] please try opening the file with the 2.0.3 snapshot using this 
code:
{code}
PDDocument doc = PDDocument.load(new File(), 
MemoryUsageSetting.setupTempFileOnly());
{code}

I could do the mentioned changes for 2.1 only. But this would make sense only 
if somebody is willing to test with a huge file on a system with a lot of 
memory.

{{RandomAccessBufferedFileInputStream}} is a special case. It extends 
{{InputStream}} and implements {{RandomAccessRead}}. Both have {{available}}.


was (Author: tilman):
Another thought about this: I possibly didn't notice last year that 
RandomAccessBuffer is for buffers in memory only.

@Brad Baker please try opening the file with the 2.0.3 snapshot using this code:
{code}
PDDocument doc = PDDocument.load(new File(), 
MemoryUsageSetting.setupTempFileOnly());
{code}

I could do the mentioned changes for 2.1 only. But this would make sense only 
if somebody is willing to test with a huge file on a system with a lot of 
memory.

{{RandomAccessBufferedFileInputStream}} is a special case. It extends 
{{InputStream}} and implements {{RandomAccessRead}}. Both have {{available}}.

> IndexOutOfBounds Exception when loading large PDF
> -------------------------------------------------
>
>                 Key: PDFBOX-2920
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2920
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Parsing
>    Affects Versions: 1.8.8, 1.8.9, 1.8.10
>         Environment: Software
>            Reporter: Brad Baker
>              Labels: parser
>
> I'm getting exceptions loading large pdfs (~6-8 GB each). I've tried using 
> PDDocument.load() and PDDocument.loadNonSeq(). I can't attach a PDF due to 
> the file size limit of 10 Mb. If there is another way to get it to someone, I 
> can work that out. Here is my code:
>       
>       public static void main(String[] args) {
>               
>               LOGGER.info("Test Large PDF Load " + TEST_PDF);
>               try {
>                       LOGGER.info("Create Steam");
>                       InputStream is = new FileInputStream(TEST_PDF);
>                       LOGGER.info("Start Load");
>                       PDDocument doc = PDDocument.load(is);
> //                    PDDocument doc = PDDocument.loadNonSeq(is, null);
>                       LOGGER.info("Finished Load");
>                       doc.close();
>                       is.close();
>               } catch (IOException e) {
>                       e.printStackTrace();
>               }
>       }
> This first error is using PDDocument.load()
> Aug 06, 2015 1:31:14 PM hp.pdfbox.test.Main main
> INFO: Test Large PDF Load D:\workspace_trunk_luna\test_pdfbox\pdfs\ELOISA 
> ARTOLA CD17433_Indigo.pdf
> Aug 06, 2015 1:31:14 PM hp.pdfbox.test.Main main
> INFO: Create Steam
> Aug 06, 2015 1:32:44 PM hp.pdfbox.test.Main main
> INFO: Start Load
> org.apache.pdfbox.exceptions.WrappedIOException
> at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:278)
> at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1219)
> at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1186)
> at hp.pdfbox.test.Main.main(Main.java:22)
> Caused by: java.lang.IndexOutOfBoundsException: Index: 1041, Size: 1041
> at java.util.ArrayList.rangeCheck(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.io.RandomAccessBuffer.seek(RandomAccessBuffer.java:110)
> at 
> org.apache.pdfbox.io.RandomAccessFileOutputStream.write(RandomAccessFileOutputStream.java:106)
> at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
> at java.io.BufferedOutputStream.flush(Unknown Source)
> at java.io.FilterOutputStream.close(Unknown Source)
> at org.apache.pdfbox.pdfparser.BaseParser.parseCOSStream(BaseParser.java:616)
> at org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:650)
> at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:203)
> ... 3 more
> This error was using PDDocument.loadNonSeq()
> INFO: Create Steam
> Aug 06, 2015 1:51:47 PM hp.pdfbox.test.Main main
> INFO: Start Load
> Aug 06, 2015 1:53:39 PM org.apache.pdfbox.pdfparser.XrefTrailerResolver 
> setStartxref
> WARNING: Did not found XRef object at specified startxref position 8552119825
> Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 509, 
> Size: 509
> at java.util.ArrayList.rangeCheck(Unknown Source)
> at java.util.ArrayList.get(Unknown Source)
> at org.apache.pdfbox.io.RandomAccessBuffer.seek(RandomAccessBuffer.java:110)
> at 
> org.apache.pdfbox.io.RandomAccessFileOutputStream.write(RandomAccessFileOutputStream.java:106)
> at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
> at java.io.BufferedOutputStream.flush(Unknown Source)
> at java.io.FilterOutputStream.close(Unknown Source)
> at 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser.parseCOSStream(NonSequentialPDFParser.java:1847)
> at 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser.parseObjectDynamically(NonSequentialPDFParser.java:1448)
> at 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser.parseObjectDynamically(NonSequentialPDFParser.java:1374)
> at 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser.parseDictObjects(NonSequentialPDFParser.java:1348)
> at 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser.initialParse(NonSequentialPDFParser.java:429)
> at 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser.parse(NonSequentialPDFParser.java:915)
> at org.apache.pdfbox.pdmodel.PDDocument.loadNonSeq(PDDocument.java:1305)
> at org.apache.pdfbox.pdmodel.PDDocument.loadNonSeq(PDDocument.java:1288)
> at hp.pdfbox.test.Main.main(Main.java:22) 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to