public virtual FileResult Print(bool landscape) { var filename = string.Format("print{0}.pdf", landscape ? "-landscape" : ""); var cd = new System.Net.Mime.ContentDisposition { FileName = filename, Inline = true }; var pdfGenerator = new PdfGenerator(); //pdfGenerator.StyleSheets.Add("~/Content/bootstrap.css"); pdfGenerator.Configuration.StyleSheets.Add("~/Content/site.css"); pdfGenerator.Configuration.Landscape = landscape; pdfGenerator.Configuration.MasterName = "~/Views/Shared/_Layout.cshtml"; var model = new IndexModel() { ShowButtons = false }; var content = pdfGenerator.GetDocument("~/Views/Home/Index.cshtml", model); this.Response.AppendHeader("Content-Disposition", cd.ToString()); return(new FileContentResult(content, "application/pdf")); }
public ActionResult FormSample() { var model = new FormSampleModel(); var cd = new System.Net.Mime.ContentDisposition { FileName = "form.pdf", Inline = true }; var pdfGenerator = new PdfGenerator(); var content = pdfGenerator.GetDocument("~/Views/Home/FormSample.cshtml", model); this.Response.AppendHeader("Content-Disposition", cd.ToString()); return(new FileContentResult(content, "application/pdf")); }