[英]PDF Box getXObjectNames() does not recognize bar code on my PDF, however it does recognize it on a PDF file I got off the internet
[英]I'm trying to load a PDF using PDF Box however, the PDF just wont open. I'm not sure whats wrong in my code
“我不确定这里到底是什么问题,所以如果有人有任何建议,请随时向我提出建议。我全神贯注!”
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"
很可能是一个目录。 您的文件可能命名为"C:\\\\Users\\\\Cayde\\\\OneDrive\\\\Desktop\\\\myfile.pdf"
。
您保存图像的文件很可能也是一个目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.