【发布时间】:2018-09-10 12:37:45
【问题描述】:
如何在 ASP.NET Core MVC 2.0 中将 html 转换为 pdf?已经尝试过使用 pdf random,但它在 Azure 中发布后抛出错误。错误说
找不到模块 'jsreport-core' azure。
以下是使用的代码:
module.exports = function (callback, html) {
var jsreport = require('jsreport-core')()
jsreport.init().then(function () {
return jsreport.render({
template: {
content: newHtml,
engine: 'jsrender',
recipe: 'phantom-pdf',
}
}).then(function (resp) {
callback(null, resp.content.toJSON().data);
});
}).catch(function (e) {
callback(e, null);
})
};
此代码在未在 Azure 门户中发布时可以正常工作。发布后,它会抛出上述突出显示的错误。已经采取的一些步骤是: 将 node.exe 添加到根文件夹。部署后不知何故无法加载js库(jsreport-core,jsreport-core,phantom-pdf)。
【问题讨论】:
-
嗨@SharadhaR,你能发布你的代码吗?这样就更容易帮助你了!
-
点评来源:请添加您的源代码并用“.netcore”标签替换您的一些标签。
-
添加源代码
标签: azure asp.net-core-mvc pdf-generation asp.net-core-mvc-2.0 jsreport