"Im not sure exactly what the problem is here so if anyone has any suggestions feel free to hit me with it. I am all ears!"
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
//Loading an existing PDF document
File file = new File("C:\\Users\\Cayde\\OneDrive\\Desktop");
PDDocument document = PDDocument.load(file);
//Instantiating the PDFRenderer class
PDFRenderer renderer = new PDFRenderer(document);
//Rendering an image from the PDF document
BufferedImage image = renderer.renderImage(0);
try {
//Writing the image to a file
ImageIO.write(image, "JPEG", new File("C:\\Users\\Cayde\\OneDrive\\Desktop\\Open"));
} catch (IOException ex) {
Logger.getLogger(AFTO781.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("Image created");
//Closing the document
document.close();
} catch (IOException ex) {
Logger.getLogger(AFTO781.class.getName()).log(Level.SEVERE, null, ex);
}
"C:\\\\Users\\\\Cayde\\\\OneDrive\\\\Desktop"
is most likely a directory. Your file is likely named like "C:\\\\Users\\\\Cayde\\\\OneDrive\\\\Desktop\\\\myfile.pdf"
.
The File where you are saving the image is most likely also a directory.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.