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

Parsing PDF as MD fails in production in Nextjs 14 #80

Open
danybeltran opened this issue Jan 19, 2024 · 2 comments
Open

Parsing PDF as MD fails in production in Nextjs 14 #80

danybeltran opened this issue Jan 19, 2024 · 2 comments

Comments

@danybeltran
Copy link

danybeltran commented Jan 19, 2024

Parsing PDF as MD fails in production in Nextjs 14

Parsing a pdf file as MD works fine in development, but fails in production, showing this error:

image

This is my typescript code:

async function getPDFContext(file: File) {
  if (file) {
    const pdf2md = require("@opendocsg/pdf2md")

    const pdfBuffer = await file.arrayBuffer()

    const pdfContent = await pdf2md(pdfBuffer)

    return pdfContent
  } else {
    return null
  }
}

To Reproduce
In a Next.js app:

  1. Create a file input
  2. Open a pdf and parse it (should work)
  3. Build with npm run build
  4. Repeat step 2 (it fails)

Desktop:

  • OS: Windows 11 64bit
  • Browser: Chrome
  • Version: 120.0.6099.224 (Official Build) (64-bit)
@ranon-rat
Copy link

I am having a similar problem but instead of needing to define the path it doesnt works in the client, it tells me

Error: Setting up fake worker failed: "Failed to resolve module specifier 'pdfjs-dist/legacy/build/pdf.worker'".
    at eval (pdf.mjs:17147:36)

@LoneRifle
Copy link
Collaborator

@ranon-rat @danybeltran please retry with v0.2.0 and close the issue if it works now. Dependency on pdfjs-dist has been removed

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

3 participants