Incorporating the PDF Viewer Component from this source into an Angular 7 project has been a challenge. The documentation clearly states:
The default worker is loaded from cdnjs.cloudflare.com.
My goal is to load the worker from a local path within my project. Despite checking out this section of the documentation, I couldn't find specific instructions on how to achieve this.
What I've Attempted:
After installing pdfjs-dist
using npm install
, I located a pdf.worker.min.js
file which I placed in the shared
folder of my project.
In my main-area.component.ts
:
...
import * as pdfjsLib from 'pdfjs-dist/build/pdf';
...
ngOnInit() {
pdfjsLib.GlobalWorkerOptions.workerSrc = '../assets/pdf.worker.min.js';
....
}
Upon page load, browser's network tab indicates successful detection of the local file. However, the console displays: Warning: Setting up fake worker.
Can anyone provide guidance on setting up the worker correctly? Thank you!