从JS Report

时间:2018-06-05 13:20:55

标签: pdf-generation asp.net-core-2.0 jsreport

我正在尝试使用Js报告创建pdf,但是它给出错误,我使用的代码是 在视图中:

   <h1>Test Application</h1><h1>Test data</h1>

在控制器中:

[MiddlewareFilter(typeof(JsReportPipeline))]
    public IActionResult CreatePdf()
    {
        HttpContext.JsReportFeature().Recipe(Recipe.ElectronPdf);
        return View("Index1");
    }

并在startup.cs

services.AddMvc();
services.AddJsReport(new LocalReporting()
.UseBinary(JsReportBinary.GetBinary())
.AsUtility()
.Create());

我安装了这三个版本 jsreport.AspNetCore -Version 1.0.1 jsreport.Local -Version 1.1.2 jsreport.Binary -Version 1.10.0 错误是:

  

处理请求时发生未处理的异常。   JsReportBinaryException:呈现报告时出错:实例已经   成功进行守护和初始化(pid:6056)渲染   完成错误:错误:尝试执行时发生错误   命令:atCriticalError([eval]:29603:25)at [eval]:29558:13   在promise._settlePromiseFromHandler的tryCatcher([eval]:36038:23)   ([eval]:34061:31)在Promise._settlePromise([eval]:34118:18)at at   Promise._settlePromises的Promise._settlePromise0([eval]:34163:10)   ([eval]:34238:18)at Async._drainQueue([eval]:31008:16)at at   Instant.Async.drainQueues中的Async._drainQueues([eval]:31018:10)   [as_onImmediate]([eval]:30892:14)at processImmediate [as   _immediateCallback](timers.js:396:17){&#34; originalError&#34;:{&#34; remoteStack&#34;:&#34;错误:命令失败:   C:\ Users \用户swapnil \应用程序数据\本地\温度\ 2 \ jsreport \编译\ jsreport-1.10.0-rJLPefJIG \ phantomjs.exe   --ignore-ssl-errors = yes --web-security = false --ssl-protocol = any C:\ Users \ swapnil \ AppData \ Local \ Temp \ 2 \ jsreport \ compile \ jsreport-1.10.0-rJLPefJIG \ standaloneScript.js   C:\ Users \用户swapnil \应用程序数据\本地\温度\ 2 \ jsreport \ 6df52490-68bd-11e8-95df-47fc0392390csettings.html \ n \ n   在ChildProcess.exithandler(child_process.js:214:12)\ n,在emitTwo   (events.js:87:13)\ n在ChildProcess.emit(events.js:172:7)\ n at   maybeClose(internal / child_process.js:854:16)\ n at   Process.ChildProcess._handle.onexit   (internal / child_process.js:222:5)&#34;}}(原始)错误:错误期间   渲染报告:命令失败:   C:\ Users \用户swapnil \应用程序数据\本地\温度\ 2 \ jsreport \编译\ jsreport-1.10.0-rJLPefJIG \ phantomjs.exe   --ignore-ssl-errors = yes --web-security = false --ssl-protocol = any C:\ Users \ swapnil \ AppData \ Local \ Temp \ 2 \ jsreport \ compile \ jsreport-1.10.0-rJLPefJIG \ standaloneScript.js   C:\ Users \用户swapnil \应用程序数据\本地\温度\ 2 \ jsreport \ 6df52490-68bd-11e8-95df-47fc0392390csettings.html   at [eval]:36644:23在ConcatStream。 ([eval]:42366:43)at   emitNone(events.js:72:20)在ConcatStream.emit(events.js:166:7)at at   finishMaybe([eval]:4229:14)at afterWrite([eval]:4115:3)at at   process._tickCallback中的nextTickCallbackWithManyArgs(node.js:486:18)   (node.js:384:17){&#34; remoteStack&#34;:&#34;错误:命令失败:   C:\ Users \用户计算机\应用程序数据\本地的\ Temp \ 2 \ jsreport \编译\ jsreport-1.10.0-rJLPefJIG \ phantomjs.exe   --ignore-ssl-errors = yes --web-security = false --ssl-protocol = any C:\ Users \ Computer \ AppData \ Local \ Temp \ 2 \ jsreport \ compile \ jsreport-1.10.0-rJLPefJIG \ standaloneScript.js   C:\ Users \用户计算机\应用程序数据\本地的\ Temp \ 2 \ jsreport \ 6df52490-68bd-11e8-95df-47fc0392390csettings.html \ n \ n   在ChildProcess.exithandler(child_process.js:214:12)\ n,在emitTwo   (events.js:87:13)\ n在ChildProcess.emit(events.js:172:7)\ n at   maybeClose(internal / child_process.js:854:16)\ n at   Process.ChildProcess._handle.onexit   (内部/ child_process.js:222:5)&#34;}

2 个答案:

答案 0 :(得分:0)

我使用

解决了这个问题
[MiddlewareFilter(typeof(JsReportPipeline))]
public IActionResult CreatePdf()
{
    HttpContext.JsReportFeature().Recipe(Recipe.ElectronPdf);
    return PartialView("Index1");
}

答案 1 :(得分:0)

在 2021 年,我将 jsreport.Binary 从 (2.9.0) 更新到 (2.11.0),错误消失了。 谢谢