jsreport.local + jsreport.Binary .NET core 2.0 web API



  • Hi!,
    I am trying to integrate jsreport into my .NET core 2.0 application as a Web API. At the moment, I am at the stage of trying to render a pdf with just an inline-template but I keep getting an exception when I try to use renderAsync(). I am hoping to try and return a memoryStream or a byte[]. Any help would be appreciated!

            var rs = new LocalReporting().KillRunningJsReportProcesses().UseBinary(JsReportBinary.GetBinary())
                .Configure(cfg => cfg.AllowLocalFilesAccess().BaseUrlAsWorkingDirectory())
                .AsUtility()
                .Create(); 
            try{
                var report = await rs.RenderAsync(new RenderRequest()
                {
                    Template = new Template()
                    {
                        Recipe = Recipe.PhantomPdf,
                        Engine = Engine.Handlebars,
                        Content = @"Test"
                    }
                });
                var memoryStream = new MemoryStream();
                await report.Content.CopyToAsync(memoryStream);
                memoryStream.Seek(0, SeekOrigin.Begin);
                return memoryStream.GetBuffer();
    
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString());
            }
    

    Error:
    jsreport.Local.JsReportBinaryException: Error rendering report: instance has been daemonized and initialized successfully (pid: 12400) 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":{"response":{"statusCode":502,"headers":{"via":"1.1 TMG-PXYBK7P002","connection":"close","proxy-connection":"close","pragma":"no-cache","cache-control":"no-cache","content-type":"text/html","content-length":"4340 "},"request":{"uri":{"protocol":"http:","slashes":true,"auth":null,"host":"localhost:56184","port":"56184","hostname":"localhost","hash":null,"search":null,"query":null,"pathname":"/api/report","path":"/api/report","href":"http://localhost:56184/api/report"},"method":"POST","headers":{"Content-Type":"application/json","proxy-authorization":"Basic cWhcd2FsZHJvbm46bmVpbGZyMmc=","content-length":166}}}}}(Original) Error: Unknown error, status code 502 at [eval]:36648:21 at ConcatStream.<anonymous> ([eval]:42366:43) at emitNone (events.js:72:20) at ConcatStream.emit (events.js:166:7) at finishMaybe ([eval]:4229:14) at endWritable ([eval]:4239:3) at ConcatStream.Writable.end ([eval]:4209:41) at IncomingMessage.onend (_stream_readable.js:498:10) at IncomingMessage.g (events.js:260:16) at emitNone (events.js:72:20) at IncomingMessage.emit (events.js:166:7) at endReadableNT (_stream_readable.js:923:12) at nextTickCallbackWith2Args (node.js:464:9) at process._tickCallback (node.js:378:17) {"response":{"statusCode":502,"headers":{"via":"1.1 TMG-PXYBK7P002","connection":"close","proxy-connection":"close","pragma":"no-cache","cache-control":"no-cache","content-type":"text/html","content-length":"4340 "},"request":{"uri":{"protocol":"http:","slashes":true,"auth":null,"host":"localhost:56184","port":"56184","hostname":"localhost","hash":null,"search":null,"query":null,"pathname":"/api/report","path":"/api/report","href":"http://localhost:56184/api/report"},"method":"POST","headers":{"Content-Type":"application/json","proxy-authorization":"Basic cWhcd2FsZHJvbm46bmVpbGZyMmc=","content-length":166}}}}
    at jsreport.Local.Internal.LocalUtilityReportingService.<RenderAsync>d__10.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
    at Iht.Api.Controllers.PdfController.<InvoiceAsync>d__2.MoveNext() in C:\git\IHT\Iht.Api\Controllers\PdfController.cs:line 64


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.