Closed panilya closed 10 months ago
Getting the same error. +1!
I have the same issue. I am working on a next.js project and try to use this library in a route handler.
It works perfectly fine in development mode. As soon as I build the project, I get the same error.
I could find out where the error gets triggered, but don't understand why.
This is line triggers it:
const fontDataPath = path.join( path.resolve(require.resolve('pdfjs-dist'), '../../standard_fonts'), '/')
https://github.com/opengovsg/pdf2md/blob/master/lib/util/pdf.js#L19
I managed to solve this by updated the next.config.mjs
file by adding:
/** @type {import('next').NextConfig} */
const config = {
experimental: {
serverComponentsExternalPackages: ['@opendocsg/pdf2md', 'pdfjs-dist'],
}
// ...
};
export default config;
This isn't due to support for ArrayBuffers (it's there, and as https://github.com/opengovsg/pdf2md/issues/69#issuecomment-1787541630 demonstrates, working as intended), but due to Webpack mangling symbols when bundling.
This hence looks like a duplicate of #76, which better describes the issue.
Duplicate of #76
Hello, thank you for your library, it's exactly what I need.
I don't know, maybe it's not bug, just me.
Describe the bug I try to parse PDF file from Buffer, but I get following error while doing so:
This is my code:
I know it's possible to create temp file, but in my case it will be better to not create any additional files.
Thank you!
P.S: passing path as a string also doesn't work (temp files)