Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow overriding pdfjs.GlobalWorkerOptions.workerSrc #180

Closed
Janhouse opened this issue Sep 30, 2023 · 7 comments
Closed

Allow overriding pdfjs.GlobalWorkerOptions.workerSrc #180

Janhouse opened this issue Sep 30, 2023 · 7 comments

Comments

@Janhouse
Copy link

Could we somehow pass the value of pdfjs.GlobalWorkerOptions.workerSrc to the component? It is currently hardcoded to a CDN and I do not want to make outside requests.

@vnt-83
Copy link

vnt-83 commented Oct 2, 2023

#157

@vnt-83
Copy link

vnt-83 commented Oct 2, 2023

I found workaround:

1) In file node_modules/@cyntler/react-doc-viewer/dist/cjs/renderers/pdf/index.js comment line17:

react_pdf_1.pdfjs.GlobalWorkerOptions.workerSrc = "https://unpkg.com/pdfjs-dist@".concat(react_pdf_1.pdfjs.version, "/legacy/build/pdf.worker.min.js");

2) In file node_modules/@cyntler/react-doc-viewer/dist/esm/renderers/pdf/index.js comment line 12:

pdfjs.GlobalWorkerOptions.workerSrc = "https://unpkg.com/pdfjs-dist@".concat(pdfjs.version, "/legacy/build/pdf.worker.min.js");

and add after (instead of) it this line:

pdfjs.GlobalWorkerOptions.workerSrc = "/js/pdf.worker.min.js";

3) Put pdf.worker.min.js to js folder in you public folder.
pdf.worker.min.js take from CDN or from node_modules/pdfjs-dist/legacy/build/ folder.

@Janhouse
Copy link
Author

Janhouse commented Oct 2, 2023

That is not a workaround. That requires making changes to the module itself.

@vnt-83
Copy link

vnt-83 commented Oct 2, 2023

Yes, but it works. There is always a choice: allow external requests or do something. When external requests are not allowed, then there is no choice.

@Janhouse
Copy link
Author

Janhouse commented Oct 2, 2023

How about adding an option to this library?

@vnt-83
Copy link

vnt-83 commented Oct 3, 2023

I would love to, but unfortunately there is no such opportunity.

@cyntler
Copy link
Owner

cyntler commented Oct 9, 2023

@Janhouse workerSrc has been fixed yesterday at the newest version.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants