OiO.lk Blog pdf Integrate pdf.js into a JavaFX Application without adding the entire pdf.js repository
pdf

Integrate pdf.js into a JavaFX Application without adding the entire pdf.js repository


I’m working on a JavaFX application where I want to integrate pdf.js to display PDF files. However, I’m looking for a way to do this without having to include a large number of files from the pdf.js repository directly into my project.

So far, I’ve found this following ways to do it:

  1. PDFBox: this way renders only pdf to image so the interaction with my pdf will be limited so I don’t prefer it
  2. Using system’s default PDF viewer: there is no problem with this approach but i want to integrate viewer into my app so i will consider it later.
  3. iText: It’s too complicated for my app, i just want to use some basics features like render, zoom in, zoom out, hightlight, etc.

4. PDF.js: This is the example about on how to use pdf.js on JavaFX 11 https://github.com/Searen1984/pdfjs4JFX (I like this way but there are some problems with me, so hope you guys can help me to configure it. By the way, I’m currently using JavaFX 21.0.4 with JDK 17)

This approach (4) needs to include many files into resources folder, and it will make my project become larger, which I’d prefer to avoid. I am thinking about using the following ways to do it:

  1. Using WebJars or other Maven dependencies: I’m have never used Webjars so I’m unsure how to configure it properly to work with my JavaFX’s WebView.

  2. Using a CDN for pdf.js and pdf.worker.js: I have never used this one before too.

I’d appreciate some guidance on: Is there any another way to set up pdf.js in a JavaFX project without including all the files from the pdf.js repository, or how to configure my 2 above ways to work seamlessly with my JavaFX WebView.

Thank you very much for reading and helping me.



You need to sign in to view this answers

Exit mobile version