JS Report with Recipe.Wkhtmltopdf in ASP.NET core 2
-
I am not able to generate pdf from html using Recipe.Wkhtmltopdf in my asp.net core application. Here is my code to generate pdf:
...
string html = System.IO.File.ReadAllText("Template/chart.html");
var report = await rs.RenderAsync(new RenderRequest
{
Template = new Template
{
Recipe = Recipe.Wkhtmltopdf,
Engine = Engine.Handlebars,
Content = html,
Wkhtmltopdf = new Wkhtmltopdf
{
AllowLocalFileAccess
}
},
Data = FaultResult()})
...
Please help me resolve the issue.
-
Here is the error:
Error rendering report: instance has been daemonized and initialized successfully (pid: 35596)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: Recipe 'wkhtmltopdf' not found\n at jsreportRuntime.js:138931:13\n at tryCatcher (jsreportRuntime.js:47291:23)\n at Promise._settlePromiseFromHandler (jsreportRuntime.js:45313:31)\n at Promise._settlePromise (jsreportRuntime.js:45370:18)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at Promise._resolveCallback (jsreportRuntime.js:45233:57)\n at Promise._settlePromiseFromHandler (jsreportRuntime.js:45325:17)\n at Promise._settlePromise (jsreportRuntime.js:45370:18)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at PromiseArray._resolve (jsreportRuntime.js:45704:19)\n at PromiseArray._promiseFulfilled (jsreportRuntime.js:45722:14)\n at Promise._settlePromise (jsreportRuntime.js:45375:26)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at Promise._settlePromise (jsreportRuntime.js:45383:21)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at Promise._resolveCallback (jsreportRuntime.js:45255:14)\n at Promise._settlePromiseFromHandler (jsreportRuntime.js:45325:17)\n at Promise._settlePromise (jsreportRuntime.js:45370:18)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at Promise._resolveCallback (jsreportRuntime.js:45233:57)\n at Promise._settlePromiseFromHandler (jsreportRuntime.js:45325:17)\n at Promise._settlePromise (jsreportRuntime.js:45370:18)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at Promise._resolveCallback (jsreportRuntime.js:45233:57)\n at Promise._settlePromiseFromHandler (jsreportRuntime.js:45325:17)\n at Promise._settlePromise (jsreportRuntime.js:45370:18)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at jsreportRuntime.js:44730:21\n at nextTickCallbackWith0Args (node.js:442:9)\n at process._tickCallback (node.js:371:13)"}}(Original) Error: Error during rendering report: Recipe 'wkhtmltopdf' not found 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: Recipe 'wkhtmltopdf' not found\n at jsreportRuntime.js:138931:13\n at tryCatcher (jsreportRuntime.js:47291:23)\n at Promise._settlePromiseFromHandler (jsreportRuntime.js:45313:31)\n at Promise._settlePromise (jsreportRuntime.js:45370:18)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at Promise._resolveCallback (jsreportRuntime.js:45233:57)\n at Promise._settlePromiseFromHandler (jsreportRuntime.js:45325:17)\n at Promise._settlePromise (jsreportRuntime.js:45370:18)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at PromiseArray._resolve (jsreportRuntime.js:45704:19)\n at PromiseArray._promiseFulfilled (jsreportRuntime.js:45722:14)\n at Promise._settlePromise (jsreportRuntime.js:45375:26)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at Promise._settlePromise (jsreportRuntime.js:45383:21)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at Promise._resolveCallback (jsreportRuntime.js:45255:14)\n at Promise._settlePromiseFromHandler (jsreportRuntime.js:45325:17)\n at Promise._settlePromise (jsreportRuntime.js:45370:18)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at Promise._resolveCallback (jsreportRuntime.js:45233:57)\n at Promise._settlePromiseFromHandler (jsreportRuntime.js:45325:17)\n at Promise._settlePromise (jsreportRuntime.js:45370:18)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at Promise._resolveCallback (jsreportRuntime.js:45233:57)\n at Promise._settlePromiseFromHandler (jsreportRuntime.js:45325:17)\n at Promise._settlePromise (jsreportRuntime.js:45370:18)\n at Promise._settlePromise0 (jsreportRuntime.js:45415:10)\n at Promise._settlePromises (jsreportRuntime.js:45494:18)\n at Promise._fulfill (jsreportRuntime.js:45439:18)\n at jsreportRuntime.js:44730:21\n at nextTickCallbackWith0Args (node.js:442:9)\n at process._tickCallback (node.js:371:13)"}
-
hi! according to your error logs, the exact error is
Recipe 'wkhtmltopdf' not found
.wkhtmltopdf
recipe is not part of default jsreport, you need to install it separately, did you install it? if no, here are the steps to do in order to install custom extensions
-
I am not able to install jsreport-wkhtmltopdf in the jsreport folder. It is always going to my C:\Users\h263351\node_modules\jsreport-wkhtmltopdf folder. Do you have any idea how can i do that. I have run npm install jsreport-wkhtmltopdf from my project jsreport folder. But it always goes to my nodemodules folder.
-
And if you can send me any sample project with example will be a great help. In the documentation there is very less they have mentioned.
-
try this, in your jsreport folder create a
package.json
with{ "name": "jsreport-local" }
, then try to runnpm install jsreport-wkhtmltopdf
again.unfortunately i don't have any sample project with custom extensions in .net prepared so it can take a while, so better to try the simple things first.
-
Yes, creating package.json in current folder should help. Otherwise npm installs to the top node_modules if that is found.