x)- [ ] Regression (a behavior that used to work and stopped working in a new release)
- [ ] Bug report -> please search issues before submitting
- [x] Feature request
- [x] Documentation issue or request
Based on some network issues, I have added pdfjs-dist to my package.json. Then I found I can set custom path to the worker... Can I use the bundled pdfjs-dist instead of downloading one?
Thank you for reply!
@kuba007 you can set custom path to the worker like this: https://github.com/VadimDez/ng2-pdf-viewer#set-custom-path-to-the-worker
And regarding bundled pdfjs-dist - i'm not using it only because it causes problems with webpack right now...
This solved it for me.
dependencies:
"@angular/core": "^6.0.0",
"ng2-pdf-viewer": "^5.0.1",
resolutions:
"pdfjs-dist": "2.0.489",
"@types/pdfjs-dist": "^0.1.2"
I'm making a mobile app that can view pdfs offline using the <pdf-viewer> element. I needed to customize the worker path due to cloudflare not being listed in our <meta> content security policy or available offline, but did need to add the following, http: for localhost development, file: for cordova android/ios and electron mac/win/linux.
worker-src http: file:;
Similar to ng2-pdf-viewer itself, my app is also using webpack.
In the client before the component containing the <pdf-viewer> element is constructed:
declare let window: any;
window.pdfWorkerSrc = require('pdfjs-dist/webpack');
I no longer get the error Warning: Setting up fake worker. pdf.js 351 and my own animated loading spinner on the page no longer noticeably freezes/is choppy during the pdf's rendering, indicating that pdf rendering is no longer processing on the UI-thread, but instead on the worker-thread.
I found this solution for webpack users of pdfjs-dist in issue 7612, here.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
This solved it for me.
I'm making a mobile app that can view pdfs offline using the
<pdf-viewer>element. I needed to customize the worker path due to cloudflare not being listed in our<meta>content security policy or available offline, but did need to add the following, http: for localhost development, file: for cordova android/ios and electron mac/win/linux.Similar to ng2-pdf-viewer itself, my app is also using webpack.
In the client before the component containing the
<pdf-viewer>element is constructed:I no longer get the error
Warning: Setting up fake worker. pdf.js 351and my own animated loading spinner on the page no longer noticeably freezes/is choppy during the pdf's rendering, indicating that pdf rendering is no longer processing on the UI-thread, but instead on the worker-thread.I found this solution for webpack users of pdfjs-dist in issue 7612, here.