Reputation: 11
error message
this is the pdf error Error: Setting up fake worker failed: "Cannot load script at: https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.5.207/pdf.worker.min.js".
using the ng2-pdf-viewer version 6.0.0
Upvotes: 0
Views: 925
Reputation: 359
I downloaded the pdf.worker.min.js library from the repository.
Then I added the path in the angular.json, in the root directory of the project.
{
"glob": "pdf.worker.min.js",
"input": "node_modules/pdfjs-dist/build/",
"output": "/assets/js/"
}
And finally, add the following code to your component:
(<any>window).pdfWorkerSrc = 'assets/js/pdf.worker.js';
With that it is already displayed correctly on the devices, but I don't know why this problem occurs, because in the browser it worked fine. If you find out more share!
Upvotes: 1