简体   繁体   中英

add pdf file to a jeditorpane in swing java

I am trying to open pdf file in jeditorPane its opening the pdf page but not in the actual format but in binary format .Is it possible to open pdf file in jeditorpane or jtextpane. I am using the following code.

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

JEditorPane does not support PDF format by default. If you implement the appropriate EditorKit , you could make it work but I believe this would be a very tedious work to perform.

However it seems that Adobe has provided a Java bean PDF viewer that you could probably integrate in your application to display a PDF. Have a look at this article .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM