【问题标题】:generate pdf from json array objects with proper tabular format从具有适当表格格式的 json 数组对象生成 pdf
【发布时间】:2019-09-24 01:14:54
【问题描述】:

我想使用 node.js 从 json 数组生成 pdf,我希望这些在 aws lambda 和 node.js 中使用。我使用了许多库,但 id 不起作用,请指导我如何实现这一点

【问题讨论】:

    标签: node.js pdf aws-lambda


    【解决方案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();
    });
    

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

    结果:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-28
      • 2011-08-10
      • 2018-12-06
      • 2020-12-01
      • 2011-08-29
      • 1970-01-01
      • 2022-11-01
      相关资源
      最近更新 更多