public JsonResult GeneratePreBill(BillRequest billRequest) { bool isEnglishBilling; var preBill = _billRepo.GeneratePreBill(billRequest, out isEnglishBilling); //Report setup var details = preBill.BillDetails.Select(d => new { BillDetailType = Convert.ToInt32(d.BillDetailType), FixedAmount = d.FixedAmount, UnitRate = d.UnitRate, Quantity = d.Quantity, Subtotal = d.Subtotal, Description = d.Description, TaxesAmount = d.TaxesAmount }).ToList(); string basePath = _hostingEnvironment.ContentRootPath; string fullPath = basePath + @"/Reports/Bill.rdlc"; FileStream inputStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read); ReportDataSourceCollection dataSources = new ReportDataSourceCollection(); dataSources.Add(new ReportDataSource { Name = "BillDataSet", Value = details }); Syncfusion.ReportWriter.ReportWriter writer = new Syncfusion.ReportWriter.ReportWriter(inputStream, dataSources); //Setting up the parameters List <ReportParameter> parameters = new List <ReportParameter>(); //IsEnglish ReportParameter isEnglishParam = new ReportParameter(); isEnglishParam.Name = "IsEnglish"; isEnglishParam.Values = new List <string>() { isEnglishBilling ? "1" : "0" }; //IsBilled ReportParameter isBilledParam = new ReportParameter(); isBilledParam.Name = "IsBilled"; isBilledParam.Values = new List <string>() { "0" }; //ClientName ReportParameter clientNameParam = new ReportParameter(); clientNameParam.Name = "ClientName"; clientNameParam.Values = new List <string>() { preBill.BillName }; //BillingPeriod string culture = isEnglishBilling ? "en" : "es"; string billingPeriod = $"{CultureInfo.GetCultureInfoByIetfLanguageTag(culture).DateTimeFormat.GetMonthName(DateTime.UtcNow.AddHours(-6).Month)} - {preBill.BillYear}"; ReportParameter billingPeriodParam = new ReportParameter(); billingPeriodParam.Name = "BillingPeriod"; billingPeriodParam.Values = new List <string>() { billingPeriod }; //Subtotal ReportParameter subTotalExpenseParam = new ReportParameter(); subTotalExpenseParam.Name = "Subtotal"; subTotalExpenseParam.Values = new List <string>() { preBill.BillSubtotal.ToString() }; //Discount ReportParameter discountParam = new ReportParameter(); discountParam.Name = "Discount"; discountParam.Values = new List <string>() { preBill.BillDiscount.ToString() }; //Taxes ReportParameter taxesParam = new ReportParameter(); taxesParam.Name = "Taxes"; taxesParam.Values = new List <string>() { preBill.Taxes.ToString() }; //TotalExpense ReportParameter totalParam = new ReportParameter(); totalParam.Name = "Total"; totalParam.Values = new List <string>() { preBill.Total.ToString() }; //TotalExpense ReportParameter billDateParam = new ReportParameter(); billDateParam.Name = "BillDate"; billDateParam.Values = new List <string>() { preBill.BillDate.ToString("dd/MM/yyyy") }; parameters.Add(isEnglishParam); parameters.Add(isBilledParam); parameters.Add(clientNameParam); parameters.Add(billingPeriodParam); parameters.Add(subTotalExpenseParam); parameters.Add(discountParam); parameters.Add(taxesParam); parameters.Add(totalParam); parameters.Add(billDateParam); writer.SetParameters(parameters); writer.ReportProcessingMode = ProcessingMode.Local; MemoryStream memoryStream = new MemoryStream(); writer.Save(memoryStream, WriterFormat.PDF); memoryStream.Position = 0; FileStreamResult fileStreamResult = new FileStreamResult(memoryStream, "application/pdf"); fileStreamResult.FileDownloadName = $"FacturaCliente{preBill.BillName}deMes{preBill.BillMonth}YAño{preBill.BillYear}.pdf"; return(Json(new { result = memoryStream.ConvertToBase64() })); }