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:
- Is there any external component or library to view pdf in JavaFX? It should be a freeware.
- (If I have to use
JPedal
) How can I embed it in my application.
You can try with iText too,i work with it in java A tutorial about how to use it
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!!!
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