if (pdfobj.isStream()) {
PdfStream stream = (PdfStream) pdfobj;
PdfObject pdfsubtype = stream.get(PdfName.SUBTYPE);
if (pdfsubtype != null) {
if (pdfsubtype.toString().equals(PdfName.IMAGE.toString())) {
PdfImageObject image = new PdfImageObject((PRStream) stream);
BufferedImage bufferedImage = image.getBufferedImage();
if (bufferedImage != null) {
String pngName = IdUtils.getUniqueID() + ".png";
File pngFile = new File(tmpDirectory, pngName);
FileOutputStream out = new FileOutputStream(pngFile);
ImageIO.write(bufferedImage, "png", out);