Displaying pdf in JavaFX

2019-01-07 12:01发布

Developing a desktop application in JavaFX which requires to display a pdf. I read that there is no support for pdf viewing/displaying in JavaFX(current version), I read about JPedal too.

Now, questions:

  1. Is there any external component or library to view pdf in JavaFX? It should be a freeware.
  2. (If I have to use JPedal) How can I embed it in my application.

标签: java javafx
9条回答
时光不老,我们不散
2楼-- · 2019-01-07 12:58

You can try with iText too,i work with it in java A tutorial about how to use it

查看更多
Ridiculous、
3楼-- · 2019-01-07 13:01

I have written a quite simple example using web views and pdf.js, here is the source code available on GitHub:

https://github.com/enriquezrene/curso-javafx-udemy/tree/master/clase-17/curso-javafx

Enjoy it!!!

查看更多
狗以群分
4楼-- · 2019-01-07 13:03

I suggest using PDF JS javascript library.

Create a WebView and load statically the html/javascript content of this javascript pdf viewer example project. Create a function in javascript to which you can send the pdf byte array to be displayed.

This way all the logic of the pdf viewer is already there. You can even modify the viewers html to remove some features over there.

Also be careful about JPedalFX as I found it not reliable in cases where it had to render images that were added to the pdf file. In my case JPedalFX could not render a chart image that was generated with jfreechart

查看更多
登录 后发表回答