mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
47.17k stars 9.82k forks source link

Failed to update from version 3.0.279 to 4.2.67 of pdfjs-dist #18212

Closed stefanheinze closed 4 weeks ago

stefanheinze commented 4 weeks ago

Because of a security vulnerability we need to update in our product the pdfjs-dist version from 3.0.279 to 4.2.67.

We have the library integrated in an angular 17 application, so the application runs in a browser.

In version 3.0.279 our setups looked like that. We have the depenedency added to our package.json and initialize the pdfjs library when our module is created.

import * as pdfJs from 'pdfjs-dist';
import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry';

export function loadPdfJs() {
  pdfJs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
  return pdfJs;
} 

After initializing the library we can use it in our component:

this.loadingTask = this.pdfJs.getDocument(src);
....

In version 4.2.67 we tried to initialize the library in the same way:

import * as pdfJs from 'pdfjs-dist';
import * as pdfWorker from 'pdfjs-dist/build/pdf.worker.mjs';

export function loadPdfJs() {
  pdfJs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
  return pdfJs;
} 

But the pdfJs can not be loaded, therefore i can not set the worker. I saw also different ways to set the worker (by url or whatever). But i can not go the first step.

Can someone help on that topic. For us its very urgend these days to do the update to a newer version.