Exemple #1
0
        public IActionResult Get()
        {
            var report = _jsreportService.RenderAsync(new RenderRequest()
            {
                Template = new Template
                {
                    Content = "<h1>Hello world -> {{name}}</h1>",
                    Engine  = Engine.Handlebars,
                    Recipe  = Recipe.ChromePdf
                },
                Data = new
                {
                    name = "Cemre"
                }
            }).Result;

            return(File(report.Content, report.Meta.ContentType));
        }
Exemple #2
0
        public async Task <Stream> ExportAsync(DtoResume resume)
        {
            var dict = _modelBuilder.Build(resume);

            var result = await _engine.CompileRenderAsync(_viewPath, dict);

            var report = await _reportMVCService.RenderAsync(new RenderRequest()
            {
                Template = new Template
                {
                    Content = result,
                    Engine  = Engine.None,
                    Recipe  = Recipe.ChromePdf
                }
            });

            return(report.Content);
        }
Exemple #3
0
        public async Task <(string ContentType, MemoryStream stream)> GenerateStream
            (string viewPath, object model, Recipe type)
        {
            var routeData       = _accessor.HttpContext.GetRouteData();
            var jsReportFeature = new JsReportFeature(_accessor.HttpContext);

            jsReportFeature.Recipe(type);
            jsReportFeature.RenderRequest.Template.Content = await
                                                             RenderViewToStringAsync(_accessor.HttpContext, routeData, viewPath, viewPath, model)
                                                             .ConfigureAwait(false);

            var report = await _jsReportMVCService.RenderAsync(jsReportFeature.RenderRequest)
                         .ConfigureAwait(false);

            var contentType  = report.Meta.ContentType;
            var memoryStream = new MemoryStream();

            report.Content.CopyTo(memoryStream);
            return(contentType, memoryStream);
        }