I am trying to create pdf with Js report but its giving error,The code I used is In View:
<h1>Test Application</h1><h1>Test data</h1>
In Controller:
[MiddlewareFilter(typeof(JsReportPipeline))]
public IActionResult CreatePdf()
{
HttpContext.JsReportFeature().Recipe(Recipe.ElectronPdf);
return View("Index1");
}
And In startup.cs
services.AddMvc();
services.AddJsReport(new LocalReporting()
.UseBinary(JsReportBinary.GetBinary())
.AsUtility()
.Create());
and I have installed these three versions jsreport.AspNetCore -Version 1.0.1 and jsreport.Local -Version 1.1.2 and jsreport.Binary -Version 1.10.0 The error is:
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\2\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\2\jsreport\compile\jsreport-1.10.0-rJLPefJIG\standaloneScript.js C:\Users\swapnil\AppData\Local\Temp\2\jsreport\6df52490-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\2\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\2\jsreport\compile\jsreport-1.10.0-rJLPefJIG\standaloneScript.js C:\Users\swapnil\AppData\Local\Temp\2\jsreport\6df52490-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\2\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\2\jsreport\compile\jsreport-1.10.0-rJLPefJIG\standaloneScript.js C:\Users\Computer\AppData\Local\Temp\2\jsreport\6df52490-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)"}
I solved this by using
[MiddlewareFilter(typeof(JsReportPipeline))]
public IActionResult CreatePdf()
{
HttpContext.JsReportFeature().Recipe(Recipe.ElectronPdf);
return PartialView("Index1");
}