Skip to content

import * as pdfjsLib from "pdfjs-dist/build" issues. #17622

Closed Answered by i-dkz
i-dkz asked this question in Q&A
Discussion options

You must be logged in to vote

Here were my fixes:

In Next.js implementation:

  • install react-pdf (this uses pdfjs)
  • ensure that pdfjs and anything related is removed from node_modules and uninstalled
  • put 'import { pdfjs } from react-pdf ' in whichever file you're using it in
  • define pdfjs worker ( pdfjs.GlobalWorkerOptions.workerSrc = //unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js; )

In vanilla html file implementation

  • i downloaded the pdfjs.min.mjs and pdfjsworker.min.mjs files and served them with my project

In Astro/HTMX/Alpine.js implementation - my newest version

  • similar to next.js only i was forced to use the CDN as i am not using react for this
  • <script src="https://unpkg.com/pdfjs-dist@4.0.37…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@i-dkz
Comment options

@piotrberlowski
Comment options

Comment options

You must be logged in to vote
2 replies
@tiagodreis
Comment options

@joshuasoup
Comment options

Answer selected by i-dkz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #17621 on February 04, 2024 09:04.