Convert Pdf buffer to jpg image buffer ( NodeJS )

Viewed 6150

I have extracted a PDF attachment from email and i have the content of PDF file like : Buffer ff 34 54 ,I want to convert this buffer to jpg image buffer. So that i can convert the the PDF to jpg image. Is there a way to convert the buffer directly?

I have saved the pdf file then using some third party module, I have converted that to jpg. But for that I have to write and read files many times.

1 Answers

Maybe this could help. Just googled pdf to image and got this.

npm install pdf-image

var PDFImage = require("pdf-image").PDFImage;
var pdfImage = new PDFImage("/tmp/slide.pdf");
pdfImage.convertFile().then(function (imagePaths) {
// [ /tmp/slide-0.png, /tmp/slide-1.png ]

});
Related