Baki created PDFBOX-3522:
----------------------------
Summary: SEVERE: Cannot read JPEG2000 image
Key: PDFBOX-3522
URL: https://issues.apache.org/jira/browse/PDFBOX-3522
Project: PDFBox
Issue Type: Bug
Reporter: Baki
I'm getting this error when trying to do the conversion.
I researched a lot but could not find the solution. Can you help me please ? It
is in the sample file.
pom.xml:
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.3</version>
</dependency>
Error:
Eki 04, 2016 2:57:52 PM org.apache.pdfbox.contentstream.PDFStreamEngine
operatorException
SEVERE: Cannot read JPEG2000 image: Java Advanced Imaging (JAI) Image I/O Tools
are not installed
Eki 04, 2016 2:57:52 PM org.apache.pdfbox.contentstream.PDFStreamEngine
operatorException
SEVERE: Cannot read JPEG2000 image: Java Advanced Imaging (JAI) Image I/O Tools
are not installed
public class PdfToPicture {
private static ArrayList<String> picturesList = new ArrayList<>();
public static ArrayList<String> getPicturesPath(String pdfFilePath) {
try {
String pdfFilename = pdfFilePath;
PDDocument document = PDDocument.load(new File(pdfFilename));
PDFRenderer pdfRenderer = new PDFRenderer(document);
for (int page = 0; page < document.getNumberOfPages(); ++page) {
// BufferedImage bufferedImage =
pdfRenderer.renderImageWithDPI(page, 80, ImageType.RGB);
BufferedImage bufferedImage = pdfRenderer.renderImage(page);
String filename = pdfFilename + "-" + (page + 1) + ".png";
ImageIO.write(bufferedImage, "PNG", new File(filename));
picturesList.add(filename);
}
document.close();
} catch (OperatorStreamException operatorStreamException){
System.out.println("operatorStreamException error" +
operatorStreamException.getMessage());
} catch (UnsupportedOperationException onSupportedOperationException){
System.out.println("throwable error" +
onSupportedOperationException.getMessage());
} catch (Exception e) {
System.out.println("Pdf error" + e.getMessage());
} catch (Throwable throwable){
System.out.println("throwable error" + throwable.getMessage());
}
return picturesList;
}
}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]