I used pdf.js directly in angular app for some pdf purposes. It works fine.
I imported the pdfjs from the pdfjs-dist and my package.json includes pdfjs-dist.
I solved this by using the pre-built version pdfjs-dist and including the file pdf.worker.min.js in scripts
"assets": [
"src/assets",
"src/favicon.ico"
],
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
],
"scripts": [
"node_modules/bootstrap/dist/js/bootstrap.js",
"node_modules/pdfjs-dist/build/pdf.worker.min.js"
]
}
then you shoud import the pdfjs-dist
import * as PDFJS from "pdfjs-dist";
PDFJS.GlobalWorkerOptions.workerSrc = "pdf.worker.js";