importjava.awt.image.BufferedImage;importjava.io.File;importjavax.imageio.ImageIO;importorg.apache.pdfbox.pdmodel.PDDocument;importorg.apache.pdfbox.rendering.PDFRenderer;publicclassExtractImageFromPdf{publicstaticvoidmain(String args[])throwsException{//Loading an existing PDF document File file =newFile("C:/pdfBox/ExtractImage_IP.pdf");PDDocument document =PDDocument.load(file);//Instantiating the PDFRenderer class PDFRenderer renderer =newPDFRenderer(document);//Rendering an image from the PDF document BufferedImage image = renderer.renderImage(0);//Writing the image to a file ImageIO.write(image,"JPEG",newFile("C:/pdfBox/ExtractImage_OP.png"));System.out.println("Image created");//Closing the document
document.close();}}