使用正确的表格格式从json数组对象生成pdf

时间:2019-05-06 11:45:52

标签: node.js pdf aws-lambda

我想使用node.js从json数组生成pdf,并且我希望它们在使用node.js的aws lambda中使用很多库,但是id无法正常工作,请您指导我如何做到这一点

1 个答案:

答案 0 :(得分: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();
});

我们可以使用pdfkit节点模块和JSON.stringfy

结果:
enter image description here

相关问题