コード例 #1
0
        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");
        }
コード例 #2
0
        public ActionResult StatementFiredPdf(string sid, DateTime? dateFired)
        {
            var data = new StatementFired();
            data.SidEmployee = sid;
            data.DateFired = dateFired.Value;
            data.Configure();

            return View("StatementFired", data);
        }