What should be the value for `workerSrc`?
See original GitHub issueLink to PDF file (or attach file here):
Configuration:
- Web browser and its version: Chrome 57.0.2987.133
- Operating system and its version: OSX 10.11.6
- PDF.js version: 1.7.365
- Is an extension: bundled via webpack 2.2.1
I tried to follow the documentation for webpack but it’s not working (keep getting setting up fake worker), probably due to me not understanding what exactly should go into workerSrc
.
Is workerSrc
:
- a URL that’ll get resolved by the browser? e.g.
PDFJS.workerSrc = '/pdf.worker.js';
- a Node require spec that’ll get resolved and bundled into the same file via webpack & node?
e.g.
PDFJS.workerSrc = 'pdfjs-dist/build/pdf.worker.js';
- a relative path that’ll get resolved and bundled into the same file via webpack & node?
e.g.
PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
- something else?
Thanks for any pointers.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:18 (4 by maintainers)
Top Results From Across the Web
CSP: worker-src - HTTP - MDN Web Docs
The HTTP Content-Security-Policy (CSP) worker-src directive specifies valid sources for Worker, SharedWorker, or ServiceWorker scripts.
Read more >No PDFJS.workerSrc specified - Stack Overflow
I had a similar error and I fixed it by specifying the pdf.worker.js explicitly at the end of the pdf.js if (!PDFJS.workerSrc &&...
Read more >Examples
This tutorial shows how PDF.js can be used as a library in a web browser. ... window['pdfjs-dist/build/pdf']; // The workerSrc property shall be...
Read more >CSP: worker-src - HTTP - UDN Web Docs: MDN Backup
The server must generate a unique nonce value each time it transmits a policy. It is critical to provide an unguessable nonce, as...
Read more >How to add worker-src to the trusted sources of Web Security ...
As a workaround, the worker-src can be set into the 'Content Security ... Add the worker-src blob:; at the Http header value field...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try this:
I use Pdfjs v2.8.335 with legacy supporting in this way:
import * as pdfjsLib from ‘pdfjs-dist/legacy/build/pdf’ import PDFJSWorker from ‘pdfjs-dist/legacy/build/pdf.worker.entry’
pdfjsLib.GlobalWorkerOptions.workerSrc = PDFJSWorker