I'm getting a problem using PDFBox API. I have a PDF file with a JBIG2 image in it and I want to read it out and create a JPEG or PNG file with the PDF content. Unfortunately I'm only getting a black image.
My code is:
public static void copyDocumentAsImage(String path) throws IOException {
PDDocument document = PDDocument.load(new File(path));
String destinationDir = "myDestinationPath";
BufferedImage img = new BufferedImage(2000, 2000, BufferedImage.TYPE_BYTE_GRAY);
PDXObjectImage ximage = new PDJpeg(document, img);
ximage.write2file(destinationDir);
}
I already checked this: https://issues.apache.org/jira/i#browse/PDFBOX-1067
But it did not work for me or I not getting the right solution.
Can someone help me out with it?
Thanks in advance.