jsreport / jsreport-dotnet

jsreport .NET sdk home repository
https://jsreport.net
MIT License
63 stars 10 forks source link

JsReportException: Unable to render template. #29

Closed pedrommuller closed 2 years ago

pedrommuller commented 5 years ago

I'm using JSReport service as the following: in my configuration services services.AddJsReport(new ReportingService(settings.Endpoint,settings.User, settings.Password));

[MiddlewareFilter(typeof(JsReportPipeline))]
        public async  Task<ActionResult> DownloadPdf(int id = 0)
        {
            string fileName = $"quote-report-{DateTime.UtcNow.Ticks}.pdf";

            HttpContext.JsReportFeature().DebugLogsToResponse().Recipe(Recipe.ChromePdf)
                .OnAfterRender((r) => HttpContext.Response.Headers["Content-Disposition"] = $"attachment; filename=\"{fileName}\"")
                .Configure((r) => r.Template.Chrome = new Chrome {
                    DisplayHeaderFooter = false,
                    PrintBackground = true,
                    MarginTop = "2cm",
                    MarginLeft = "1.8cm",
                    MarginBottom = "2cm",
                    MarginRight = "1.8cm"
                }).Engine(Engine.JsRender);

            return await Review(id);
        }

Review is another action result at the end returns a view with the model populated that we reuse somewhere else

in the JsReport studio I'm getting this exception:

Engine must be specified Error: Engine must be specified at module.exports (/usr/src/app/node_modules/jsreport-core/lib/util/createError.js:9:13) at Reporter.createError (/usr/src/app/node_modules/jsreport-core/lib/reporter.js:263:12) at invokeRender (/usr/src/app/node_modules/jsreport-core/lib/render/render.js:30:20) at module.exports (/usr/src/app/node_modules/jsreport-core/lib/render/render.js:134:11) at

+0 Starting rendering request 307538 (user: ***) +3 Rendering anonymous template { recipe: undefined, engine: undefined } +4 Data item not defined for this template. +4 Resources not defined for this template.

it works when I use the local binary approach, any ideas?

pofider commented 5 years ago

I tried to replicate this with basically the same code, but no luck. Would you be able to replicate the issue in a simple sample repository? What jsreport version do you use in the remote server?

pedrommuller commented 5 years ago

The remote server is jsReport online, the subdomain is https://prtx.jsreportonline.net/

I can try to create a brand new project for this

pofider commented 2 years ago

A lot has changed in the jsreport v3 sdk, please test it there and come back if you have still troubles.