Details
Description
After successfully loading a PDF document and extracting pages from it using the following snippet:
doc = PDDocument.load(f);
pages = doc.getDocumentCatalog().getAllPages();
I try and convert the front page to an image as follows:
PDPage page = (PDPage) pages.get(0);
BufferedImage image = page.convertToImage();
The page.convertToImage() causes a RuntimeException to be thrown due to an uncaught internal IOException. Otherwise, the extracting of text/images and all other functions I tried work correctly on this document.
Here is the stack trace:
Exception in thread "main" java.lang.RuntimeException: java.io.IOException: The handle is invalid
at org.apache.pdfbox.pdfparser.PDFStreamParser$1.tryNext(PDFStreamParser.java:149)
at org.apache.pdfbox.pdfparser.PDFStreamParser$1.hasNext(PDFStreamParser.java:158)
at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:241)
at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:208)
at org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:112)
at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:722)
at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:693)
at pdfboxtestant.Main.getFrontPageImage(Main.java:44)
at pdfboxtestant.Main.main(Main.java:25)
Caused by: java.io.IOException: The handle is invalid
at java.io.RandomAccessFile.seek(Native Method)
at org.apache.pdfbox.io.RandomAccessFile.seek(RandomAccessFile.java:59)
at org.apache.pdfbox.io.RandomAccessFileInputStream.read(RandomAccessFileInputStream.java:96)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at java.io.FilterInputStream.read(FilterInputStream.java:66)
at java.io.PushbackInputStream.read(PushbackInputStream.java:122)
at org.apache.pdfbox.io.PushBackInputStream.read(PushBackInputStream.java:84)
at org.apache.pdfbox.pdfparser.BaseParser.skipSpaces(BaseParser.java:1296)
at org.apache.pdfbox.pdfparser.PDFStreamParser.parseNextToken(PDFStreamParser.java:197)
at org.apache.pdfbox.pdfparser.PDFStreamParser.access$000(PDFStreamParser.java:47)
at org.apache.pdfbox.pdfparser.PDFStreamParser$1.tryNext(PDFStreamParser.java:146)
... 8 more
Attachments
Attachments
Issue Links
- is related to
-
PDFBOX-708 Failed to create Type1C font. Falling back to Type1 font
- Closed