Convert PDF to PNG - Java 10 gives a different result than Java 8

I want to convert PDF to PNG file.

But for some responses, Java 10 gives a different PNG than Java 8

private static void writeImageToPath(BufferedImage buff, String path, int pageWidth, int pageHeight) throws IOException {

File outputfile = new File(path);

Image image = buff.getScaledInstance(pageWidth, pageHeight, Image.SCALE_SMOOTH);

BufferedImage bufferedImage = new BufferedImage(pageWidth, pageHeight, BufferedImage.TYPE_INT_ARGB);

Graphics2D g2d = bufferedImage.createGraphics();

g2d.drawImage(image, 0, 0, null);

g2d.setColor(Color.BLACK);

g2d.dispose();

ImageIO.write(bufferedImage, "png", outputfile);

}

I read that the compression settings have changed in Java 9 PNG writer, so that might be why I'm seeing different results from Java 8. github.com/gredler/jdk9-png-writer-backport

Do you know how can I overcome this issue?...

Read More »

By: StackOverFlow - Tuesday, 6 November

Related Posts