Skip to content

Commit 4e85e14

Browse files
author
Anton Kiselev
committed
update worker links
1 parent b62620b commit 4e85e14

File tree

9 files changed

+49
-17
lines changed

9 files changed

+49
-17
lines changed

examples/components/pageviewer.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ if (!pdfjsLib.getDocument || !pdfjsViewer.PDFPageView) {
1818
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
1919
}
2020

21+
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
22+
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
23+
import.meta.url
24+
);
2125
// The workerSrc property shall be specified.
2226
//
23-
pdfjsLib.GlobalWorkerOptions.workerSrc =
24-
"../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
27+
// pdfjsLib.GlobalWorkerOptions.workerSrc =
28+
// "../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
2529

2630
// Some PDFs need external cmaps.
2731
//

examples/components/simpleviewer.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) {
1818
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
1919
}
2020

21+
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
22+
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
23+
import.meta.url
24+
);
2125
// The workerSrc property shall be specified.
2226
//
23-
pdfjsLib.GlobalWorkerOptions.workerSrc =
24-
"../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
27+
// pdfjsLib.GlobalWorkerOptions.workerSrc =
28+
// "../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
2529

2630
// Some PDFs need external cmaps.
2731
//

examples/components/singlepageviewer.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ if (!pdfjsLib.getDocument || !pdfjsViewer.PDFSinglePageViewer) {
1818
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
1919
}
2020

21+
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
22+
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
23+
import.meta.url
24+
);
2125
// The workerSrc property shall be specified.
2226
//
23-
pdfjsLib.GlobalWorkerOptions.workerSrc =
24-
"../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
27+
// pdfjsLib.GlobalWorkerOptions.workerSrc =
28+
// "../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
2529

2630
// Some PDFs need external cmaps.
2731
//

examples/learning/helloworld64.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ <h1>'Hello, world!' example</h1>
3131
'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' +
3232
'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G');
3333

34+
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
35+
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
36+
import.meta.url
37+
);
3438
//
3539
// The workerSrc property shall be specified.
3640
//
37-
pdfjsLib.GlobalWorkerOptions.workerSrc =
38-
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs';
41+
// pdfjsLib.GlobalWorkerOptions.workerSrc =
42+
// '../../node_modules/pdfjs-dist/build/pdf.worker.mjs';
3943

4044
// Opening PDF by passing its binary data as a string. It is still preferable
4145
// to use Uint8Array, but string or array-like structure will work too.

examples/learning/prevnext.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ <h1>'Previous/Next' example</h1>
2828
//
2929
var url = '../../web/compressed.tracemonkey-pldi-09.pdf';
3030

31+
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
32+
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
33+
import.meta.url
34+
);
3135
//
3236
// In cases when the pdf.worker.js is located at the different folder than the
3337
// PDF.js's one, or the PDF.js is executed via eval(), the workerSrc property
3438
// shall be specified.
3539
//
36-
pdfjsLib.GlobalWorkerOptions.workerSrc =
37-
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs';
40+
// pdfjsLib.GlobalWorkerOptions.workerSrc =
41+
// '../../node_modules/pdfjs-dist/build/pdf.worker.mjs';
3842

3943
var pdfDoc = null,
4044
pageNum = 1,

examples/mobile-viewer/viewer.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ const MAX_IMAGE_SIZE = 1024 * 1024;
2424
const CMAP_URL = "../../node_modules/pdfjs-dist/cmaps/";
2525
const CMAP_PACKED = true;
2626

27-
pdfjsLib.GlobalWorkerOptions.workerSrc =
28-
"../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
27+
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
28+
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
29+
import.meta.url
30+
);
31+
// pdfjsLib.GlobalWorkerOptions.workerSrc =
32+
// "../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
2933

3034
const DEFAULT_URL = "../../web/compressed.tracemonkey-pldi-09.pdf";
3135
const DEFAULT_SCALE_DELTA = 1.1;

examples/text-only/pdf2svg.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ const PAGE_NUMBER = 1;
1818
const PAGE_SCALE = 1.5;
1919
const SVG_NS = "http://www.w3.org/2000/svg";
2020

21-
pdfjsLib.GlobalWorkerOptions.workerSrc =
22-
"../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
21+
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
22+
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
23+
import.meta.url
24+
);
25+
// pdfjsLib.GlobalWorkerOptions.workerSrc =
26+
// "../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
2327

2428
function buildSVG(viewport, textContent) {
2529
// Building SVG with size of the viewport (for simplicity)

examples/webpack/main.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ import * as pdfjsLib from "pdfjs-dist";
77

88
const pdfPath = "../learning/helloworld.pdf";
99

10+
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
11+
'../../build/webpack/pdf.worker.bundle.js',
12+
import.meta.url
13+
);
1014
// Setting worker path to worker bundle.
11-
pdfjsLib.GlobalWorkerOptions.workerSrc =
12-
"../../build/webpack/pdf.worker.bundle.js";
15+
// pdfjsLib.GlobalWorkerOptions.workerSrc =
16+
// "../../build/webpack/pdf.worker.bundle.js";
1317

1418
// Loading a document.
1519
const loadingTask = pdfjsLib.getDocument(pdfPath);

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.16.105",
2+
"version": "4.6.82",
33
"build": 305,
44
"commit": "eaaa8b4"
55
}

0 commit comments

Comments
 (0)