Is there a way to convert a PDF buffer to an png image Buffer ?
All I can do is convert the pdf buffer to base 64 but then I don't know what to do next.
Thanks !
I just used https://github.com/yakovmeister/pdf2image, works good for my use case but requires some native deps :
import { fromBuffer as convertPdfToPng } from 'pdf2pic'
const pdf2picOptions = {
format: 'png',
width: 2550,
height: 3300,
density: 330,
savePath: './output/from-buffer-to-base64',
}
const convert = convertPdfToPng(pdfBuffer, pdf2picOptions)
const pageOutput = await convert(pageNumber, true)
const pngBuffer = Buffer.from(pageOutput.base64, 'base64')