从 JS 报告创建 pdf 时出错

Error while creating pdf from JS Report

我正在尝试用 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-版本1.0.1jsreport.Local - 版本 1.1.2jsreport.Binary - 版本 1.10.0 错误是:

An unhandled exception occurred while processing the request. JsReportBinaryException: Error rendering report: instance has been daemonized and initialized successfully (pid: 6056)rendering has finished with errors:Error: An error occurred while trying to execute the command: at onCriticalError ([eval]:29603:25) at [eval]:29558:13 at tryCatcher ([eval]:36038:23) at Promise._settlePromiseFromHandler ([eval]:34061:31) at Promise._settlePromise ([eval]:34118:18) at Promise._settlePromise0 ([eval]:34163:10) at Promise._settlePromises ([eval]:34238:18) at Async._drainQueue ([eval]:31008:16) at Async._drainQueues ([eval]:31018:10) at Immediate.Async.drainQueues [as _onImmediate] ([eval]:30892:14) at processImmediate [as _immediateCallback] (timers.js:396:17) {"originalError":{"remoteStack":"Error: Command failed: C:\Users\swapnil\AppData\Local\Temp\jsreport\compile\jsreport-1.10.0-rJLPefJIG\phantomjs.exe --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any C:\Users\swapnil\AppData\Local\Temp\jsreport\compile\jsreport-1.10.0-rJLPefJIG\standaloneScript.js C:\Users\swapnil\AppData\Local\Temp\jsreportdf52490-68bd-11e8-95df-47fc0392390csettings.html\n\n at ChildProcess.exithandler (child_process.js:214:12)\n at emitTwo (events.js:87:13)\n at 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)"}}(Original) Error: Error during rendering report: Command failed: C:\Users\swapnil\AppData\Local\Temp\jsreport\compile\jsreport-1.10.0-rJLPefJIG\phantomjs.exe --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any C:\Users\swapnil\AppData\Local\Temp\jsreport\compile\jsreport-1.10.0-rJLPefJIG\standaloneScript.js C:\Users\swapnil\AppData\Local\Temp\jsreportdf52490-68bd-11e8-95df-47fc0392390csettings.html at [eval]:36644:23 at ConcatStream. ([eval]:42366:43) at emitNone (events.js:72:20) at ConcatStream.emit (events.js:166:7) at finishMaybe ([eval]:4229:14) at afterWrite ([eval]:4115:3) at nextTickCallbackWithManyArgs (node.js:486:18) at process._tickCallback (node.js:384:17) {"remoteStack":"Error: Command failed: C:\Users\Computer\AppData\Local\Temp\jsreport\compile\jsreport-1.10.0-rJLPefJIG\phantomjs.exe --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any C:\Users\Computer\AppData\Local\Temp\jsreport\compile\jsreport-1.10.0-rJLPefJIG\standaloneScript.js C:\Users\Computer\AppData\Local\Temp\jsreportdf52490-68bd-11e8-95df-47fc0392390csettings.html\n\n at ChildProcess.exithandler (child_process.js:214:12)\n at emitTwo (events.js:87:13)\n at 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)"}

我用

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

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