【发布时间】:2012-03-05 16:13:31
【问题描述】:
我正在尝试使用 jpedal 的 pdf 库,使用此处找到的代码 sn-p:http://www.jpedal.org/simple_image_example.php
/**instance of PdfDecoder to convert PDF into image*/
PdfDecoder decode_pdf = new PdfDecoder(true);
/**set mappings for non-embedded fonts to use*/
FontMappings.setFontReplacements();
/**open the PDF file - can also be a URL or a byte array*/
try {
decode_pdf.openPdfFile("C:/myPDF.pdf"); //file
//decode_pdf.openPdfFile("C:/myPDF.pdf", "password"); //encrypted file
//decode_pdf.openPdfArray(bytes); //bytes is byte[] array with PDF
//decode_pdf.openPdfFileFromURL("http://www.mysite.com/myPDF.pdf",false);
/**get page 1 as an image*/
//page range if you want to extract all pages with a loop
//int start = 1, end = decode_pdf.getPageCount();
BufferedImage img=decode_pdf.getPageAsImage(1);
/**close the pdf file*/
decode_pdf.closePdfFile();
} catch (PdfException e) {
e.printStackTrace();
}
但是在这一行:
decode_pdf.openPdfFile("C:/myPDF.pdf"); //file
Eclipse 报错:
类型 javax.swing.JPanel 无法解析。是间接的 从所需的 .class 文件中引用
好像我缺少 javax.swing.*
Intellisence 确实给了我其他 javax.* 选项,但没有给我 Swing 类。
我已经在谷歌上搜索过这个,但我没有找到解决方案。
有什么想法吗?
【问题讨论】:
-
通常这是核心 java 安装的一部分。你确定你安装正确了吗?
-
实际使用的是哪个版本/类型的 java?
-
在 cmd 中使用“java -version”命令我得到:java 版本“1.7.0_02”Java(TM) SE Runtime Environment (build 1.7.0_02-b13) Java HotSpot(TM) 64- Bit Server VM(build 22.0-b10,混合模式)
-
能否在早期的 JDK 下运行相同的代码?例如。 1.6?
-
我现在要试试这个。