Node.js 从ejs模板创建和呈现pdf

Node.js 从ejs模板创建和呈现pdf,node.js,express,pdf,ejs,Node.js,Express,Pdf,Ejs,当我得到一个名为newpage的特定路径时,我尝试使用或类似的方法从ejs文件创建一个pdf文件,但没有成功 新页 router.get('/newPage', function(req, res) { ejs.renderFile('secure/new_report_print', { data: { qryWaterLab: qryWaterLab, qryWaterContact: qryWaterContac

当我得到一个名为newpage的特定路径时,我尝试使用或类似的方法从ejs文件创建一个pdf文件,但没有成功

新页

  router.get('/newPage', function(req, res) {

    ejs.renderFile('secure/new_report_print', {
        data: {
            qryWaterLab: qryWaterLab,
            qryWaterContact: qryWaterContact,
            qryResult: qryResult,
            moment: moment,
            lSystemID: req.query.lSystemID,
            LabReportID: req.query.LabReportID
        },
        function(err, result) {
            // render on success
            if (result) {
                html =
                result;
            } else {
                res.end('An error occurred');
                console.log(err);
            }
          }
        });

        var options = {
            filename: 'report.pdf',
            format: 'A4',
            orientation: 'portrait',
            directory: './pdfs/',
            type: "pdf"
        };

        pdf.create(html, options).toFile(function(err, res) {
            if (err)
                return console.log(err);
            console.log(res);
        });