public string GenerateOrderInvoice([FromBody] Order obj) { try { List <Order> lst = this._IOrderBAL.GetOrderByOrderId(obj).Result; lst[0].OrderDetails = this._IOrderBAL.GetSuccessOrderDetailsByOrderId(obj).Result; foreach (var item in lst[0].OrderDetails) { if (item.SetNo > 0) { item.ProductImg = _utilities.ProductImage(item.ProductId, "productSetImage", webRootPath, item.SetNo); } else { item.ProductImg = _utilities.ProductImage(item.ProductId, "productColorImage", webRootPath, item.ProductSizeColorId); } } string FileName = DateTime.Now.ToString("ddMMyyyyHHmmss") + ".pdf"; var globalSettings = new GlobalSettings { ColorMode = ColorMode.Color, Orientation = Orientation.Portrait, PaperSize = PaperKind.A4, Margins = new MarginSettings { Top = 10 }, DocumentTitle = "Order Invoice Report", Out = webRootPath + "\\ReportGenerate\\" + FileName }; var objectSettings = new ObjectSettings { PagesCount = true, HtmlContent = ReportTemplate.OrderInvoiceTemplate(lst), WebSettings = { DefaultEncoding = "utf-8", UserStyleSheet = Path.Combine(Directory.GetCurrentDirectory(), "assets", "styles.css") }, HeaderSettings = { FontName = "Arial", FontSize = 9, Right = "Page [page] of [toPage]", Line = true }, FooterSettings = { FontName = "Arial", FontSize = 9, Line = true, Center = "Report Footer" } //Page = "http://ecom.uccnoida.com/shop/collection/left/sidebar" }; var pdf = new HtmlToPdfDocument() { GlobalSettings = globalSettings, Objects = { objectSettings } }; var file = _converter.Convert(pdf); //return Ok("Successfully created PDF document."); File(file, "application/pdf", FileName); //return File(file, "application/pdf"); return(FileName); } catch (Exception ex) { ErrorLogger.Log($"Something went wrong inside ReportController GenerateOrderInvoice action: {ex.Message}"); ErrorLogger.Log(ex.StackTrace); return(null); } }