-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Am on windows 10 using pnpm.
I am using pdfium inside a nextjs app route api route endpoint. When I upload a pdf to the endpoint, hoping to turn it into a png, I get this error:
Module not found: Can't resolve './'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./app/api/upload/route.ts
⨯ ../../../../node_modules/.pnpm/@hyzyla+pdfium@2.1.2/node_modules/@hyzyla/pdfium/dist/index.esm.js:1210:1
Here is the relevant code, I have installed both pdfium and sharp:
const library = await PDFiumLibrary.init();
const document = await library.loadDocument(fileBuffer);
const page = await document.getPage(0);
const image = await page.render({
scale: 3,
render: async (options: any): Promise<Uint8Array> => {
return await sharp(options.data, {
raw: {
width: options.width,
height: options.height,
channels: 4,
},
})
.png()
.toBuffer();
},
});
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels