Anyone get pdf.js working in a custom Widget?

You can use the lib pdf from Mozilla to achieve this.

You have to use the loadScript function (Using and requesting new external libraries) to load the necessary scripts (“https://mozilla.github.io/pdf.js/build/pdf.mjs” & “https://mozilla.github.io/pdf.js/build/pdf.worker.mjs”)

If the scripts are provided you have to define a pdfJSWoker which is necessary for the pdf lib then you have to load the base64 of the pdf via widget parameter or via request. So you can easily use the pdf lib samples (Examples).

Keep in mind that you have to define a function to handle more than one pdf pages.

1 Like