1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Slightly re-factor the transportFactory initialization in getDocument

Given that the `WorkerTransport`-constructor will access all possible factory-instances, let's ensure that the `transportFactory`-object always has a consistent shape regardless of other options.

Also, since `useWorkerFetch` is always true in MOZCENTRAL builds we never need to create `CMapReaderFactory`/`StandardFontDataFactory`-instances there.
This commit is contained in:
Jonas Jenwald 2024-09-24 12:48:36 +02:00
parent a1283785e5
commit a989244570

View file

@ -341,16 +341,17 @@ function getDocument(src = {}) {
const transportFactory = {
canvasFactory: new CanvasFactory({ ownerDocument, enableHWA }),
filterFactory: new FilterFactory({ docId, ownerDocument }),
cMapReaderFactory:
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
useWorkerFetch
? null
: new CMapReaderFactory({ baseUrl: cMapUrl, isCompressed: cMapPacked }),
standardFontDataFactory:
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
useWorkerFetch
? null
: new StandardFontDataFactory({ baseUrl: standardFontDataUrl }),
};
if (!useWorkerFetch) {
transportFactory.cMapReaderFactory = new CMapReaderFactory({
baseUrl: cMapUrl,
isCompressed: cMapPacked,
});
transportFactory.standardFontDataFactory = new StandardFontDataFactory({
baseUrl: standardFontDataUrl,
});
}
if (!worker) {
const workerParams = {