Does anyone have a recommended way to view a PDF file by using javafx?
4 Answers
Try the JPedalFX viewer which provides a JavaFX component for viewing PDF files.
OR
Pre-convert the PDF into JavaFX code prior to viewing using the JPedal PDF to JavaFX converter.

- 398,270
- 210
- 566
- 880

- 150,031
- 14
- 366
- 406
-
JPedal is not open source. Is there any open source api to do the same ? – DeepInJava Mar 27 '17 at 14:36
-
I don't know of any open source API for PDF display in JavaFX, [StackOverflow isn't really a place for software recommendations](https://meta.stackoverflow.com/questions/251134/where-can-i-ask-about-finding-a-tool-library-or-favorite-off-site-resource). According to StackOverflow standards, I probably shouldn't even have answered this question in the way I did. You could review some of the other answers to this question to see if any of the software recommended there helps you otherwise you can research or ask questions on a different site. – jewelsea Mar 28 '17 at 23:02
Two separate issues: PDF and display.
Java FX is your display.
You can generate PDFs using XSL-FO if you have XML to start with and like writing stylesheets, OR you can do it with Java code if you use the iText library.

- 305,152
- 44
- 369
- 561
Don't know if this is what you are looking for, this line just opens pdf files in the OS (so not embedded or anything, you'll need a program installed that can handle pdf's like Adobe Reader):
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file.getAbsolutePath());

- 3,317
- 7
- 45
- 66
The following thread from stackoverflow.com discusses different possibility to develop a pdf viewer for the javafx application. Displaying pdf in JavaFX
The following libraries can be tried for this implementation:
OpenViewerFX – An Open Source JavaFX PDF Viewer: https://www.idrsolutions.com/openviewerfx/
PDF renderer with Java: https://java.net/projects/pdf-renderer
PDF.js
JPedalFX
SwingLabs