Skip to content

Commit

Permalink
update worker links
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Kiselev committed Oct 2, 2024
1 parent b62620b commit 4e85e14
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 17 deletions.
8 changes: 6 additions & 2 deletions examples/components/pageviewer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ if (!pdfjsLib.getDocument || !pdfjsViewer.PDFPageView) {
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
}

pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
import.meta.url
);
// The workerSrc property shall be specified.
//
pdfjsLib.GlobalWorkerOptions.workerSrc =
"../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
// pdfjsLib.GlobalWorkerOptions.workerSrc =
// "../../node_modules/pdfjs-dist/build/pdf.worker.mjs";

// Some PDFs need external cmaps.
//
Expand Down
8 changes: 6 additions & 2 deletions examples/components/simpleviewer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) {
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
}

pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
import.meta.url
);
// The workerSrc property shall be specified.
//
pdfjsLib.GlobalWorkerOptions.workerSrc =
"../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
// pdfjsLib.GlobalWorkerOptions.workerSrc =
// "../../node_modules/pdfjs-dist/build/pdf.worker.mjs";

// Some PDFs need external cmaps.
//
Expand Down
8 changes: 6 additions & 2 deletions examples/components/singlepageviewer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ if (!pdfjsLib.getDocument || !pdfjsViewer.PDFSinglePageViewer) {
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
}

pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
import.meta.url
);
// The workerSrc property shall be specified.
//
pdfjsLib.GlobalWorkerOptions.workerSrc =
"../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
// pdfjsLib.GlobalWorkerOptions.workerSrc =
// "../../node_modules/pdfjs-dist/build/pdf.worker.mjs";

// Some PDFs need external cmaps.
//
Expand Down
8 changes: 6 additions & 2 deletions examples/learning/helloworld64.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ <h1>'Hello, world!' example</h1>
'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' +
'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G');

pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
import.meta.url
);
//
// The workerSrc property shall be specified.
//
pdfjsLib.GlobalWorkerOptions.workerSrc =
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs';
// pdfjsLib.GlobalWorkerOptions.workerSrc =
// '../../node_modules/pdfjs-dist/build/pdf.worker.mjs';

// Opening PDF by passing its binary data as a string. It is still preferable
// to use Uint8Array, but string or array-like structure will work too.
Expand Down
8 changes: 6 additions & 2 deletions examples/learning/prevnext.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ <h1>'Previous/Next' example</h1>
//
var url = '../../web/compressed.tracemonkey-pldi-09.pdf';

pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
import.meta.url
);
//
// In cases when the pdf.worker.js is located at the different folder than the
// PDF.js's one, or the PDF.js is executed via eval(), the workerSrc property
// shall be specified.
//
pdfjsLib.GlobalWorkerOptions.workerSrc =
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs';
// pdfjsLib.GlobalWorkerOptions.workerSrc =
// '../../node_modules/pdfjs-dist/build/pdf.worker.mjs';

var pdfDoc = null,
pageNum = 1,
Expand Down
8 changes: 6 additions & 2 deletions examples/mobile-viewer/viewer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ const MAX_IMAGE_SIZE = 1024 * 1024;
const CMAP_URL = "../../node_modules/pdfjs-dist/cmaps/";
const CMAP_PACKED = true;

pdfjsLib.GlobalWorkerOptions.workerSrc =
"../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
import.meta.url
);
// pdfjsLib.GlobalWorkerOptions.workerSrc =
// "../../node_modules/pdfjs-dist/build/pdf.worker.mjs";

const DEFAULT_URL = "../../web/compressed.tracemonkey-pldi-09.pdf";
const DEFAULT_SCALE_DELTA = 1.1;
Expand Down
8 changes: 6 additions & 2 deletions examples/text-only/pdf2svg.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ const PAGE_NUMBER = 1;
const PAGE_SCALE = 1.5;
const SVG_NS = "http://www.w3.org/2000/svg";

pdfjsLib.GlobalWorkerOptions.workerSrc =
"../../node_modules/pdfjs-dist/build/pdf.worker.mjs";
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'../../node_modules/pdfjs-dist/build/pdf.worker.mjs',
import.meta.url
);
// pdfjsLib.GlobalWorkerOptions.workerSrc =
// "../../node_modules/pdfjs-dist/build/pdf.worker.mjs";

function buildSVG(viewport, textContent) {
// Building SVG with size of the viewport (for simplicity)
Expand Down
8 changes: 6 additions & 2 deletions examples/webpack/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import * as pdfjsLib from "pdfjs-dist";

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

pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
'../../build/webpack/pdf.worker.bundle.js',
import.meta.url
);
// Setting worker path to worker bundle.
pdfjsLib.GlobalWorkerOptions.workerSrc =
"../../build/webpack/pdf.worker.bundle.js";
// pdfjsLib.GlobalWorkerOptions.workerSrc =
// "../../build/webpack/pdf.worker.bundle.js";

// Loading a document.
const loadingTask = pdfjsLib.getDocument(pdfPath);
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.16.105",
"version": "4.6.82",
"build": 305,
"commit": "eaaa8b4"
}

0 comments on commit 4e85e14

Please sign in to comment.