[
https://issues.apache.org/jira/browse/PDFBOX-2055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13987751#comment-13987751
]
Hong-Thai Nguyen commented on PDFBOX-2055:
------------------------------------------
Thank [~tilman], as you guessed, I mean effectively 'can't' ;)
For the test, I'm generating first page to an Image via API:
{code}
@VisibleForTesting
ImageResult generateImage(File localFile, int width, int height) throws
Exception {
BufferedImage image;
PDDocument document = PDDocument.load(localFile);
try {
image = computeImage(document);
} finally {
document.close();
document = null;
}
byte[] bytes = ImageResizer.resize(image, width, height);
if (bytes != null && image != null) {
return new ImageResult(bytes, "image/png", image.getWidth(),
image.getHeight());
} else {
return null;
}
}
private BufferedImage computeImage(PDDocument document) throws IOException {
PDPage page = (PDPage) document.getDocumentCatalog().getAllPages().get(0);
try {
BufferedImage image = page.convertToImage(BufferedImage.TYPE_INT_RGB,
resolution);
return image;
} finally {
page = null;
}
}
{code}
I confirm that this exception is real on 1.8.4
> IOException when converting PDF to image
> ----------------------------------------
>
> Key: PDFBOX-2055
> URL: https://issues.apache.org/jira/browse/PDFBOX-2055
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 1.8.4
> Reporter: Hong-Thai Nguyen
> Priority: Critical
> Attachments: eu_competition_newsletter_04_june_-_10_june_2010.pdf
>
>
> With attach PDF file, we got IO Exception when using PDPage.convertToImage():
> {code}
> java.io.IOException
> at org.apache.pdfbox.filter.FlateFilter.decode(FlateFilter.java:138)
> at org.apache.pdfbox.cos.COSStream.doDecode(COSStream.java:336)
> at org.apache.pdfbox.cos.COSStream.doDecode(COSStream.java:248)
> at
> org.apache.pdfbox.cos.COSStream.getUnfilteredStream(COSStream.java:183)
> at
> org.apache.pdfbox.pdfparser.PDFStreamParser.<init>(PDFStreamParser.java:107)
> at
> org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:251)
> at
> org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:235)
> at
> org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:215)
> at org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:127)
> at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:801)
> at
> com.polyspot.connector.imageservice.generators.PDFBoxImageGenerator.computeImage(PDFBoxImageGenerator.java:75)
> {code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)