2

Does anyone have a recommended way to view a PDF file by using javafx?

mark stephens
  • 3,205
  • 16
  • 19
Gramero
  • 1,835
  • 3
  • 24
  • 26

4 Answers4

5

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.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
jewelsea
  • 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
1

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.

duffymo
  • 305,152
  • 44
  • 369
  • 561
1

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());
Perneel
  • 3,317
  • 7
  • 45
  • 66
1

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
Community
  • 1
  • 1
Jino
  • 13
  • 6