有人能帮我解决在JavaSwing中显示PDF的代码中的错误吗?
这段代码是为了在swing中查看PDF,但是当我打开任何PDF时,内容都不可见,并且出现空白页面。我正在使用icepdf核心和查看器jar文件有人能帮我解决在JavaSwing中显示PDF的代码中的错误吗?,java,swing,pdf,pdfview,icepdf,Java,Swing,Pdf,Pdfview,Icepdf,这段代码是为了在swing中查看PDF,但是当我打开任何PDF时,内容都不可见,并且出现空白页面。我正在使用icepdf核心和查看器jar文件 public class PDFView{ public static void main(String[]args) { SwingController controller = new SwingController(); SwingViewBuilder factory = new SwingViewBu
public class PDFView{
public static void main(String[]args) {
SwingController controller = new SwingController();
SwingViewBuilder factory = new SwingViewBuilder(controller);
controller.setIsEmbeddedComponent(true);
DocumentViewController viewController = controller.getDocumentViewController();
JPanel viewerComponentPanel = factory.buildViewerPanel();
ComponentKeyBinding.install(controller, viewerComponentPanel);
controller.getDocumentViewController().setAnnotationCallback(
new org.icepdf.ri.common.MyAnnotationCallback(
controller.getDocumentViewController()));
JFrame applicationFrame = new JFrame();
applicationFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
applicationFrame.getContentPane().setLayout(new BorderLayout());
applicationFrame.getContentPane().add(viewerComponentPanel,BorderLayout.CENTER);
applicationFrame.getContentPane().add(factory.buildCompleteMenuBar(),BorderLayout.NORTH);
controller.setPageViewMode(DocumentViewControllerImpl.ONE_PAGE_VIEW, false);
applicationFrame.pack();
applicationFrame.setVisible(true);
}}
在这里找到截图
代码中的错误和警告
[]
PDF的输出视图
java.lang.noClassDefFoundError:com.sun.image.codec.jpeg.JPEGImageDecoder
看来你需要JPEG图像解码器
下载JAR并将其添加到构建路径库中请不要只是发布一些工具或库作为答案。至少在答案本身中演示一下。@Zoe更新了我的答案,谢谢不要发布堆栈跟踪的图像。编辑问题,将堆栈跟踪的实际文本复制并粘贴到问题中。