extract images from pdf using pdfbox

前端 未结 8 1996
刺人心
刺人心 2020-11-28 09:22

I m trying to extract images from a pdf using pdfbox. The example pdf here

But i m getting blank images only.

The code i m trying:-

public st         


        
8条回答
  •  孤独总比滥情好
    2020-11-28 09:56

    Instead of calling

    image.write2file("C:\\Users\\Pradyut\\Documents\\image" + i);
    

    You can use the ImageIO.write() static method to write the RGB image out in whatever format you need. Here I've used PNG:

    File outputFile = new File( "C:\\Users\\Pradyut\\Documents\\image" + i + ".png");
    ImageIO.write( image.getRGBImage(), "png", outputFile);
    

提交回复
热议问题