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

TypeError: pdf2json_1.default is not a constructor #326

Closed
kafraymundo opened this issue Jan 19, 2024 · 3 comments
Closed

TypeError: pdf2json_1.default is not a constructor #326

kafraymundo opened this issue Jan 19, 2024 · 3 comments

Comments

@kafraymundo
Copy link

kafraymundo commented Jan 19, 2024

Hi,
after I did the npm install and run my code (I'm trying to parse a pdf with acroform and validate the value in the fields) but it wouldn't continue due to the TypeError below.
Please help!

image

Test code:
image

@nico75005
Copy link

Did you find a solution to your problem?

@Akifcan
Copy link

Akifcan commented Mar 31, 2024

you can try this:

import * as PDFParser from 'pdf2json'

 const pdfParser = new (PDFParser as any)(null, 1)

    pdfParser.on('pdfParser_dataError', (errData: any) =>
      console.error(errData),
    )
    pdfParser.on('pdfParser_dataReady', () => {
      console.log(pdfParser.getRawTextContent())
    })

Note: I'm using nest.js

@BenteaB
Copy link

BenteaB commented Apr 1, 2024

in my case, the issue was fixed after adding "esModuleInterop": true, in tsconfig.json

@modesty modesty closed this as completed May 4, 2024
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

5 participants