Skip to content

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

@danybeltran

Description

@danybeltran

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions