将pdf文件添加到swing java中的jeditorpane

时间:2013-01-15 09:04:38

标签: java swing jeditorpane

我试图在jeditorPane中打开pdf文件,打开pdf页面但不是以实际格式而是以二进制格式打开。是否可以在jeditorpane或jtextpane中打开pdf文件。 我使用以下代码。

 try
 {
  JEditorPane pane1= new JEditorPane();
  File f1= new File("path of the pdf file");
  pane1.setPage(f1.toURL());
 }
  catch(Exception ex)
  {
  }

1 个答案:

答案 0 :(得分:2)

JEditorPane默认不支持PDF格式。如果你实现适当的EditorKit,你可以使它工作,但我相信这将是一项非常繁琐的工作。

然而,似乎Adobe提供了一个Java bean PDF查看器,您可以将其集成到应用程序中以显示PDF。看看this article