you can use http.get:
http.get('YOUR URL TO GET THE IMAGE').on('response', function(res) res.setEncoding('binary'); res.on('data', function(chunk){ buffer += chunk; }); res.on('end', function(){ fs.writeFile('PATH TO SAVE IMAGE', buffer, 'binary', function (err) { if (err){ throw err; } doc = new PDFDocument({ size: 'LETTER or any other size pdfkit offer' }); doc.image('PATH TO SAVE IMAGE', 0, 0, { fit: [WIDTH, HEIGHT] }) .fontSize(10).text('text 1', 100, 170) .fontSize(16).text('text 2', 60, 120) });
source share