Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade pdfjs-dist to v4 #936

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions imports/lib/pdf/pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export {type DocumentInitParameters} from 'pdfjs-dist/types/src/display/api';
export {type PageViewport} from 'pdfjs-dist/types/src/display/display_utils';

export const WORKER_URL = Meteor.isClient
? '/pdfjs-dist/build/pdf.worker.min.js'
: 'pdfjs-dist/legacy/build/pdf.worker.js';
? '/pdfjs-dist/build/pdf.worker.min.mjs'
: 'pdfjs-dist/legacy/build/pdf.worker.mjs';
export const CMAP_URL = Meteor.isClient
? '/pdfjs-dist/cmaps/'
: './npm/node_modules/pdfjs-dist/cmaps/';
Expand All @@ -23,12 +23,12 @@ export async function fetchPDF({
}: DocumentInitParameters) {
const pdfjs = Meteor.isClient
? await import('pdfjs-dist')
: await import('pdfjs-dist/legacy/build/pdf.js');
: await import('pdfjs-dist/legacy/build/pdf.mjs');

if (pdfjs.GlobalWorkerOptions.workerSrc === '') {
pdfjs.GlobalWorkerOptions.workerSrc = WORKER_URL;
// NOTE For CDN delivery
// pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;
// pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.mjs`;
}

return pdfjs.getDocument({
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"@fontsource/roboto/700.css": "copy public/@fontsource/roboto/",
"@fontsource/roboto/files/*.woff": "copy public/@fontsource/roboto/files/",
"@fontsource/roboto/files/*.woff2": "copy public/@fontsource/roboto/files/",
"pdfjs-dist/build/pdf.worker.min.js": "copy public/pdfjs-dist/build/",
"pdfjs-dist/build/pdf.worker.js.map": "copy public/pdfjs-dist/build/",
"pdfjs-dist/build/pdf.worker.min.mjs": "copy public/pdfjs-dist/build/",
"pdfjs-dist/build/pdf.worker.mjs.map": "copy public/pdfjs-dist/build/",
"pdfjs-dist/cmaps/": "copy public/pdfjs-dist/cmaps",
"pdfjs-dist/standard_fonts/": "copy public/pdfjs-dist/standard_fonts"
},
Expand Down Expand Up @@ -115,7 +115,7 @@
"meteor-node-stubs": "^1.2.5",
"notistack": "^3.0.1",
"papaparse": "^5.4.1",
"pdfjs-dist": "~3.11.174",
"pdfjs-dist": "~4.2.67",
"qrcode.react": "^3.1.0",
"rate-limiter-flexible": "^3.0.0",
"react": "^18.2.0",
Expand Down
Loading