public ActionResult StatementFormFired(StatementFired data) { try { data.Configure(); } catch (Exception ex) { TempData["ServerError"] = ex.Message; return View("StatementFormFired", data); } HtmlToPdf converter = new HtmlToPdf(); string url = Url.Action("StatementFiredPdf", new { sid = data.SidEmployee, dateFired = data.DateFired }); var leftPartUrl = String.Format("{0}://{1}:{2}", Request.RequestContext.HttpContext.Request.Url.Scheme, Request.RequestContext.HttpContext.Request.Url.Host, Request.RequestContext.HttpContext.Request.Url.Port); url = String.Format("{1}{0}", url, leftPartUrl); PdfDocument doc = converter.ConvertUrl(url); MemoryStream stream = new MemoryStream(); doc.Save(stream); return File(stream.ToArray(), "application/pdf"); }
public ActionResult StatementFiredPdf(string sid, DateTime? dateFired) { var data = new StatementFired(); data.SidEmployee = sid; data.DateFired = dateFired.Value; data.Configure(); return View("StatementFired", data); }