actually there are many answers for this question. But my problem is, i want to generate pdf dynamically with 5 external(URL) images. Im using PDFmake node module. it supports only two ways local and base64 format. But i don't want to store images locally. so my requirement is one function which takes url as parameter and returns base64. so that i can store in global variable and create pdfs
thanks in advance
function urlToBase(URL){
return base64;
}
var img = urlToBase('https://unsplash.com/photos/MVx3Y17umaE');
var dd = {
content: [
{
text: 'fjfajhal'
},
{
image: img,
}
]
};
var writeStream = fs.createWriteStream('myPdf.pdf');
var pdfDoc = printer.createPdfKitDocument(dd);
pdfDoc.pipe(writeStream);
pdfDoc.end();
im using PDFmake module from npm