|
Configuration:
Issue was persistent whether I did it in a Next.js project , or with just plain HTML/CSS/JS. importing in Next.js:
This causes: Unhandled Runtime Error Importing in .js file in vanilla project:I have this code in a .js file and it causes the error:
Importing in <script> directly in HTML:This actually works in development, i'm able to successfully take a pdf input and parse and extract data from it. But when I deploy it on netlify or vercel, it gets blocked due to some TextMIME error about websniffing? can't find answers anywhere. nothing's working |
Replies: 4 comments 5 replies
|
Same problem here. I just wasted two days on this :-(. While I have no fix, a workaround is to use v3 of pdfjs-dist: Note that you need to change the worker path from .mjs to .js: Some further thoughts: I suspect the problem might arise due .mjs being a module. Therefore, I tried importing it with While this avoids the mentioned error when importing only, I get the error as soon as I use getDocument()... |
|
Why was this ticket/discussion closed? I'm running into exactly same issue trying to parse PDF document in nextjs. |
|
Here were my fixes: In Next.js implementation:
In vanilla html file implementation
In Astro/HTMX/Alpine.js implementation - my newest version
With frameworks like next/astro, there's an issue since node_modules is not served, i'm not exactly sure what the right way to go about it is in astro but in next it's easy to just use react-pdf. this seemed to solve my issues and worked when i deployed to vercel |
|
I got this problem when using version 3.4.120. I simply changed it to 3.4 and it worked |
Here were my fixes:
In Next.js implementation:
//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js; )In vanilla html file implementation
In Astro/HTMX/Alpine.js implementation - my newest version