Skip to content

node packge pdfjs-dist@2.6.347 syntax error #13190

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

Closed
Even-Lau opened this issue Apr 7, 2021 · 6 comments
Closed

node packge pdfjs-dist@2.6.347 syntax error #13190

Even-Lau opened this issue Apr 7, 2021 · 6 comments

Comments

@Even-Lau
Copy link

Even-Lau commented Apr 7, 2021

Configuration:

  • PDF.js version: 2.6.347

Steps to reproduce the problem:

  1. npm install pdfjs-dist@2.6.347
  2. At node_modules/pdfjs-dist/build/pdf.js line 2413 you will get this: annotationStorage: annotationStorage?.getAll() || null, and this is definitely a syntax error.
  3. However the cdn version works fine, https://cdn.jsdelivr.net/npm/pdfjs-dist@2.6.347/build/pdf.js

A lot of same errors found at line 2771, line 2817, line 2907, line 2934, line 3488, line 3543, line 3653, line 3744 .etc

@Snuffleupagus
Copy link
Collaborator

PDF.js version: 2.6.347

First of all, that version is no longer supported; please find the latest releases at https://mozilla.github.io/pdf.js/getting_started/#download. Hence you'll need to update to either version 2.7.570 or 2.8.335.

Depending on which of the two versions you pick, please note:

@Even-Lau
Copy link
Author

Even-Lau commented Apr 7, 2021

Sorry to bother you, both version 2.7.570 and 2.8.335 get the same error: annotationStorage: annotationStorage?.serializable || null
Please check it again. @Snuffleupagus

errors found in the code:

annotationStorage: annotationStorage?.serializable || null
intentState.streamReader.cancel(new _util.AbortException(reason?.message));
if (transfers?.includes(buffer)) {
if (value.hasOwnProperty?.(i)) {
mainWorkerMessageHandler = globalThis.pdfjsWorker?.WorkerMessageHandler;
if (params.pdfBug && globalThis.FontInspector?.enabled) {
if (imageData?.data?.length > MAX_IMAGE_SIZE_TO_STORE) { pageProxy.cleanupAfterRender = true; }
annotationStorage: annotationStorage?.serializable || null,
contentDispositionFilename: this._fullReader?.filename ?? null,
return obj?.resolved || false;
if (this._pdfBug && globalThis.StepperManager?.enabled) {
return (0, _util.shadow)(this, "isFontLoadingAPISupported", !!this._document?.fonts);
if (m?.[1] >= 14) { supported = true; }
if (typeof strokeColor === "object" && strokeColor?.getPattern) {
if (glyph?.compiled) { glyph.compiled(ctx); return; }
if (initialData?.length > 0) {

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Apr 7, 2021

Sorry to bother you, both version 2.7.570 and 2.8.335 get the same error: annotationStorage: annotationStorage?.serializable || null

This clearly suggests that you didn't actually read/follow all of #13190 (comment), since the quotes (from the relevant READMEs) explain what you need to do here.

@tamuratak
Copy link
Contributor

@Snuffleupagus
Copy link
Collaborator

Once more: The answer was already provided in #13190 (comment), and it means that you'll need to import from node_modules/pdfjs-dist/es5/build/pdf.js[1] instead.


[1] Or node_modules/pdfjs-dist/legacy/build/pdf.js, when using PDF.js version 2.8.335 and above.

@dsilvestregil
Copy link

@Snuffleupagus This import doesn't work for me. Folder 'es5' not exists in node_modules

@mozilla mozilla deleted a comment from wrxpowered Jun 30, 2021
@mozilla mozilla deleted a comment from georgezouq Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants