I’m working on a NestJS project using TypeScript and trying to convert a PDF (from either a stream or a buffer) into images. I decided to use the pdf-to-img library. However, when I try to use the library, I encounter the following error:
TypeError: esModule() is not a function
Sample code
async convertPdfToImages(pdfBuffer: Buffer): Promise<void> {
try {
const images = await pdfToImg.convert(pdfBuffer); // Conversion
console.log(images);
} catch (error) {
console.error(error);
}
}
Library used: pdf-to-img
I have tried other libraries too like pdf2pic but it requires the graphics to install on the system.
Is there any alternative to it to convert the pdf to image?
I have pdf readable stream / pdf buffer
Thank you
1