Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
how to download jsreport without open using c# in .Net

I am Use JS Report for view. This code render the file and and Save in root directory. But I want file is directly download not open for view.

  var header = await _jsReportMVCService.RenderViewToStringAsync(HttpContext, RouteData, "Header", new { });
                var footer = await _jsReportMVCService.RenderViewToStringAsync(HttpContext, RouteData, "Footer", new { });
                HttpContext.JsReportFeature()
                     .Recipe(Recipe.ChromePdf)
                     .Configure((r) =>
                     {
                         //r.Options = new RenderOptions
                         //{
                         //    Timeout = 600000
                         //};
                         r.Template.Chrome = new Chrome
                         {
                             HeaderTemplate = header,
                             FooterTemplate = footer,
                             DisplayHeaderFooter = true,
                             MarginTop = "1cm",
                             MarginLeft = "2cm",
                             MarginBottom = "2cm",
                             MarginRight = "1.5cm",
                             Format = "A3"
                         };
                     });
                HttpContext.JsReportFeature().OnAfterRender((renderer) =>
                {
                    using (var file = System.IO.File.Open("EmployeesList.pdf", FileMode.Create))
                    {
                        renderer.Content.CopyTo(file);

                    }
                    renderer.Content.Seek(0, SeekOrigin.Begin);
                });
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can download a JSReport like this

[MiddlewareFilter(typeof(JsReportPipeline))]
public IActionResult InvoiceDownload()
{
            HttpContext.JsReportFeature().Recipe(Recipe.PhantomPdf)
                .OnAfterRender((r) => HttpContext.Response.Headers["Content-Disposition"] = "attachment; filename=\"myReport.pdf\"");

            return View("Invoice", InvoiceModel.Example());
}

You can get help from the official asp.net core example.

Hope this helps you

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda