Is there a way to convert multiple base64 PNG files to PDF?
Thanks
I think you are looking for this.
import fs from 'fs';
let base64String = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA';
// Remove header
let base64image = base64String.split(';base64,').pop();
fs.writeFile('filename.pdf', base64image, {encoding: 'base64'}, function(err) {
console.log('File created');
});
I was able to solve the problem using node-canvas
for more info: https://www.npmjs.com/package/canvas
Note: solution works not only for png but any image type.
Then use any pdf library to merge the pdfs like hummus