Trying to use PDF JS in a local Apache server and receiving the following error in console:
Uncaught Error: No PDFJS.workerSrc specified
This is very weird, because I'm following all that the examples specifies here http://mozilla.github.io/pdf.js/examples/.
I have, in my main folder, a sample file called file.pdf
and I'm just trying to display it. I did it by using a iframe with a file
parameter:
<iframe src="./web/viewer.html?file=http://localhost:99/PDF/arquivo.pdf" width="1800px" height="900px" />
And now I'm trying to use the JavaScript API to display it. I'm trying to do:
<!DOCTYPE html> <html> <head> <script src="./build/pdf.js" type="text/javascript"></script> <script type="text/javascript"> PDFJS.getDocument('arquivo.pdf').then(function(pdf) { // Here I use it }) </script> </head> <body> </body> </html>
If I try to include pdf.worker.js
manually, I receive:
GET http://localhost:99/PDF/build/pdf.worker.worker.js 404 (Not Found)
because it programmatically includes pdf.worker.js.
With the sample code I posted here, I receive a log and an error:
Error: No PDFJS.workerSrc specified pdf.js:249 at error (http://localhost:99/PDF/build/pdf.js:251:15) at Object.WorkerTransport (http://localhost:99/PDF/build/pdf.js:2305:9) at Object.getDocument (http://localhost:99/PDF/build/pdf.js:1805:15) at http://localhost:99/PDF/:6:10 pdf.js:251 Warning: Unsupported feature "unknown" pdf.js:234 Uncaught Error: No PDFJS.workerSrc specified
Do I need to manually specify pdf.worker.js? Please, what can I try to solve this?
Thank you so much!
(*) - I can see a lack of good content and a well explained documentation of PDF.JS.