0

I want to generate pdf from json array using node.js and i want these in aws lambda with node.js.i have used many libraries but id doesn't work can you please guide me how can i acheive this

Aditya
  • 9
  • 1
  • 6

1 Answers1

0
app.get('/pdf/', function (req, res, next) {
    var PDFDocument = require('pdfkit');
    const doc = new PDFDocument();
    var json = { list: ['Test', 'Array'], success: true }
    doc.fontSize(15)
        .fillColor('blue')
        .text(JSON.stringify(json, null, 2), 100, 100)
    // .link(100, 100, 160, 27, link);

    doc.pipe(res);

    doc.end();
});

We can use pdfkit node module and JSON.stringfy

Result:
enter image description here

Wang Liang
  • 4,244
  • 6
  • 22
  • 45