public ActionResult GetInvoicePrint(int id) { SalesInvoiceModel salesInvoiceModel = new SalesInvoiceModel(); salesInvoiceModel = _iSalesInvoiceService.GetSalesInvoiceReportById(id); string html = _iSalesInvoiceService.GetInvoiceHtmlString(salesInvoiceModel); var pdf = Pdf .From(html) .OfSize(PaperSize.Letter) .WithTitle("Title") .WithoutOutline() .WithMargins(.25.Centimeters()) .Portrait() .Comressed() .Content(); string webRootPath = _hostingEnvironment.WebRootPath; string InvoicePath = Path.Combine(webRootPath, "Sales"); string FileNmae = InvoicePath + "\\SalesInvoice_" + DateTime.UtcNow.AddMinutes(LoginInfo.Timeoffset).ToString("MM/dd/yyyy HH:mm").Replace("/", "").Replace(" ", "").Replace(":", "").ToString() + ".pdf"; Stream myStream = new MemoryStream(pdf); using (var fileStream = System.IO.File.Create(FileNmae)) { myStream.Seek(0, SeekOrigin.Begin); myStream.CopyTo(fileStream); } byte[] FileBytes = System.IO.File.ReadAllBytes(FileNmae); return(File(FileBytes, "application/pdf")); }