Java 在JFrame中打开PDF

Java 在JFrame中打开PDF,java,swing,itext,pdfbox,icepdf,Java,Swing,Itext,Pdfbox,Icepdf,我正在用java制作一个PDF阅读器,我想在我自己的应用程序的JFrame中打开PDF文件,这样我就可以制作自己的功能了。有办法吗? 我使用“iText”、“pdfBox”和“ICEpdf”来处理PDF文档 public static void pdfViewerICE() { String filePath = "PDF_URL"; // build a controller controller = new SwingController(

我正在用java制作一个PDF阅读器,我想在我自己的应用程序的JFrame中打开PDF文件,这样我就可以制作自己的功能了。有办法吗? 我使用“iText”、“pdfBox”和“ICEpdf”来处理PDF文档

  public static void pdfViewerICE() {
        String filePath = "PDF_URL";
        // build a controller
        controller = new SwingController();

        // Build a SwingViewFactory configured with the controller
        SwingViewBuilder factory = new SwingViewBuilder(controller);
           PropertiesManager properties = new PropertiesManager(
                System.getProperties(),
                 ResourceBundle.getBundle(PropertiesManager.DEFAULT_MESSAGE_BUNDLE));

   properties.set(PropertiesManager.PROPERTY_DEFAULT_ZOOM_LEVEL, "1.75");

        // Use the factory to build a JPanel that is pre-configured
        //with a complete, active Viewer UI.
       JPanel viewerComponentPanel = factory.buildViewerPanel();

        controller.openDocument(filePath);
      }
上面的代码通过java程序使用ICEPDF打开PDF。
注意:在类路径中包含ICEPDF jar(ICEPDF viewer.jar,ICEPDF-core.jar)对于PDFBox,获取源代码并查看PDFReader.java和PDFPagePanel.java。但我想说你的问题相当广泛,很可能会被标记。你可以使用
PDPage
类的方法
convertToImage
,然后在JFrame上显示图像。嘿,你能告诉我如何使用此方法打开远程PDF吗。当我将URL放到文件中时,我收到一条消息,即icepdf无法打开该文件,因为该文件已损坏,或者即使pdf很好,文件格式也不正确。