using System; using Stimulsoft.Report; using Stimulsoft.Report.Mvc; using Stimulsoft.Report.Export; using Microsoft.AspNetCore.Mvc; using System.IO; namespace DummyApi.Controllers { [Route("api/[controller]")] [ApiController] public class ReportController : Controller { [HttpGet] public IActionResult Get() { try { StiReport report = new StiReport(); report.Load(StiNetCoreHelper.MapPath(this, "Reports/DummyReport.mrt")); StiPdfExportSettings pdfSettings = new StiPdfExportSettings(); pdfSettings.EmbeddedFonts = true; StiOptions.Export.Pdf.AllowImportSystemLibraries = true; // report.Render(); // var service = new Stimulsoft.Report.Export.StiPdfExportService(); // var stream = new System.IO.MemoryStream(); // service.ExportTo(report, stream, pdfSettings); // var data = stream.ToArray(); // System.IO.File.WriteAllBytes(@".\output\dummyapi-output_" + DateTime.Now.ToString("yyyy-dd-M--HH-mm-ss") + ".pdf", data); return StiNetCoreReportResponse.ResponseAsPdf(report, pdfSettings); } catch (Exception ex) { return BadRequest(ex.ToString()); } } } }