在phantom-html2pdf之前运行一个js脚本,从html生成pdf

你好,我希望有一些关于phantom-html2pdf模块的帮助。 我想从一个HTML生成一个PDF文件,为此我使用phantomjs和phantom-html2pdf。 我的代码是:

var pdf = require('phantom-html2pdf'); exports.makePdf = function (req, res, next) { console.log("pdf function"); console.log(req.body); var html = req.body.html, css = req.body.css, js = req.body.js; var options = { "html" : html, "css" : css, "js" : js, // "runnings" : "Path to runnings file. Check further below for explanation.", "deleteOnAction" : true }; pdf.convert(options, function(result) { /* Using a buffer and callback */ result.toBuffer(function(returnedBuffer) {}); /* Using a readable stream */ var stream = result.toStream(); /* Using the temp file path */ var tmpPath = result.getTmpPath(); /* Using the file writer and callback */ result.toFile("file.pdf", function() {}); }); }; 

作为pdf.convert()的选项,我传递了html页面,该页面的css和一个添加了一些额外的html标签(含内容)的js脚本。 我的问题是,创build的pdf有外部文件正确的css规则,但它缺lessdynamic添加的js脚本(我作为选项传递的外部文件)的html标签。

任何人都可以帮我解决我的问题吗?

谢谢大家。