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

Uncaught SyntaxError: Unexpected token '<' (at pdf.worker.js:1:1) #991

Closed
4 tasks done
rd7r7 opened this issue Apr 19, 2022 · 4 comments
Closed
4 tasks done

Uncaught SyntaxError: Unexpected token '<' (at pdf.worker.js:1:1) #991

rd7r7 opened this issue Apr 19, 2022 · 4 comments
Labels
duplicate This issue or pull request already exists question Further information is requested

Comments

@rd7r7
Copy link

rd7r7 commented Apr 19, 2022

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

hello
I am using react-pdf version 5.x in my react version 18 app and it throws me the following error
Warning: Setting up fake worker.
Uncaught SyntaxError: Unexpected token '<' (at pdf.worker.js:1:1)
Captura1

Steps to reproduce


Expected behavior


Actual behavior


Additional information


Environment

  • Browser (if applicable):
  • React-PDF v 5.x:
  • React v18:
  • Webpack version (if applicable):
    Captura1
@rd7r7 rd7r7 added the bug Something isn't working label Apr 19, 2022
@wojtekmaj wojtekmaj added duplicate This issue or pull request already exists question Further information is requested and removed bug Something isn't working labels Apr 19, 2022
@wojtekmaj
Copy link
Owner

Duplicate of #97
See also #680 and others.

@luciano1997
Copy link

import { Document, Page, pdfjs } from "react-pdf";
pdfjs.GlobalWorkerOptions.workerSrc = //cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js;
this work for me

dependences
"react-pdf": "^5.7.2",

@matrolat
Copy link

matrolat commented Dec 11, 2022

Import
import { Document, Page, pdfjs } from "react-pdf";

Also add this inside your functional component
useEffect(() => { pdfjs.GlobalWorkerOptions.workerSrc =https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;});

`

@sanjar-162

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants