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

1 Answer 1

1
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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.