You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Timo Boehme (JIRA)" <ji...@apache.org> on 2013/10/14 18:16:50 UTC

[jira] [Commented] (PDFBOX-1748) PDPage.convertToImage fails with IndexOutOfBoundsException: Index: 0, Size: 0

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

Timo Boehme commented on PDFBOX-1748:
-------------------------------------

Could you please confirm, that this error also occurs with latest 1.8 version (and maybe 2.0 from SVN)?
Next can you confirm that you do not use multi-threading  (you need one PDFBox instance per thread)?
In order to reproduce the error we would need an example PDF showing this behaviour.


> PDPage.convertToImage fails with IndexOutOfBoundsException: Index: 0, Size: 0
> -----------------------------------------------------------------------------
>
>                 Key: PDFBOX-1748
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1748
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 1.7.1, 1.8.2
>            Reporter: Kurt M
>
> I am trying to create jpg images from pages in a pdf document.  The following code works in most environments, but we recently installed on a new system and are experiencing a high rate of failure there.  The same files that fail there work in other environments.
> Here is my code:
>         PDDocument doc;
>         try {           
>             RandomAccess scratchFile = new RandomAccessBuffer();           
>             doc = PDDocument.loadNonSeq( pdfFile, scratchFile );         
>             int pageNum = 0;
>             int fullRes = 96;
>             List<PDPage> pages = doc.getDocumentCatalog().getAllPages();
>             BufferedImage fullImg;
>             for( PDPage page : pages ) {
>                 pageNum++;
>                 fullImg = page.convertToImage( BufferedImage.TYPE_INT_RGB, fullRes );
> and here is the stack trace (this is from the 1.7.1 version I think):
> java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
> 	at java.util.ArrayList.get(ArrayList.java:352)
> 	at org.apache.pdfbox.io.RandomAccessBuffer.seek(RandomAccessBuffer.java:84)
> 	at org.apache.pdfbox.io.RandomAccessFileInputStream.read(RandomAccessFileInputStream.java:96)
> 	at java.io.BufferedInputStream.read1(BufferedInputStream.java:267)
> 	at java.io.BufferedInputStream.read(BufferedInputStream.java:328)
> 	at java.io.BufferedInputStream.fill(BufferedInputStream.java:229)
> 	at java.io.BufferedInputStream.read(BufferedInputStream.java:248)
> 	at java.io.FilterInputStream.read(FilterInputStream.java:77)
> 	at java.io.PushbackInputStream.read(PushbackInputStream.java:133)
> 	at org.apache.pdfbox.io.PushBackInputStream.read(PushBackInputStream.java:91)
> 	at org.apache.pdfbox.pdfparser.BaseParser.skipSpaces(BaseParser.java:1547)
> 	at org.apache.pdfbox.pdfparser.PDFStreamParser.parseNextToken(PDFStreamParser.java:230)
> 	at org.apache.pdfbox.pdfparser.PDFStreamParser.access$000(PDFStreamParser.java:46)
> 	at org.apache.pdfbox.pdfparser.PDFStreamParser$1.tryNext(PDFStreamParser.java:182)
> 	at org.apache.pdfbox.pdfparser.PDFStreamParser$1.hasNext(PDFStreamParser.java:194)
> 	at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:257)
> 	at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:237)
> 	at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:217)
> 	at org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:119)
> 	at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:730)
> 	at generateSlideImages(PDFUtils.java:213) <-- my code



--
This message was sent by Atlassian JIRA
(v6.1#6144)