public ActionResult ControllerlessPdfWithLayout() { var generator = new StandaloneGenerator(new Parser(), Server.MapPath("~")) { Templates = new List <Template> { new Template { Name = "~/Views/Shared/_PdfLayout.cshtml", Source = System.IO.File.ReadAllText(Server.MapPath("~/Views/Shared/_PdfLayout.cshtml")) } }, Margins = new Margins(10, 10, 100, 10) }; var footerModel = new FooterModel { Name = "Unicorns Rule" }; var headerModel = new HeaderModel { Name = "Unicorns Rule" }; var footerSnippet = new Footer(footerModel, Server.MapPath("~/Views/Pdf/_Footer.cshtml"), 80, 0, 0, 0); var headerSnippet = new Header(headerModel, Server.MapPath("~/Views/Pdf/_Header.cshtml"), 80, 0, 0, 0); generator.AddPageSnippet(footerSnippet); generator.AddPageSnippet(headerSnippet); var pdf = generator.GeneratePdf(GetModel(), Server.MapPath("~/Views/Pdf/ControllerlessPdfWithLayout.cshtml")); return(new FileContentResult(pdf, "application/pdf")); }
public ActionResult LandscapeControllerlessPdfWithoutLayout() { var generator = new StandaloneGenerator(new Parser(), Server.MapPath("~")); var footerModel = new FooterModel { Name = "Unicorns Rule" }; var headerModel = new HeaderModel { Name = "Unicorns Rule" }; var footerSnippet = new Footer(footerModel, Server.MapPath("~/Views/Pdf/_Footer.cshtml"), 50, 5, 5, 10); var headerSnippet = new Header(headerModel, Server.MapPath("~/Views/Pdf/_Header.cshtml"), 50, 5, 5, 10); generator.AddPageSnippet(footerSnippet); generator.AddPageSnippet(headerSnippet); var pdf = generator.GeneratePdf( (writer, document) => { document.SetPageSize(PageSize.A4.Rotate()); }, GetModel(), Server.MapPath("~/Views/Pdf/ControllerlessPdfWithoutLayout.cshtml")); return(new FileContentResult(pdf, "application/pdf")); }
public ActionResult ControllerlessPdfWithoutLayout() { var generator = new StandaloneGenerator(new Parser(), Server.MapPath("~")); var pdf = generator.GeneratePdf(GetModel(), Server.MapPath("~/Views/Pdf/ControllerlessPdfWithoutLayout.cshtml")); return(new FileContentResult(pdf, "application/pdf")); }
public ActionResult LandscapeControllerlessPdfWithoutLayout() { var generator = new StandaloneGenerator(new Parser(), Server.MapPath("~")); var pdf = generator.GeneratePdf( (writer, document) => { document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); }, GetModel(), Server.MapPath("~/Views/Pdf/ControllerlessPdfWithoutLayout.cshtml")); return(new FileContentResult(pdf, "application/pdf")); }
public ActionResult ControllerlessPdfWithoutLayout() { var generator = new StandaloneGenerator(new Parser(), Server.MapPath("~")); var model = new FooterModel { Name = "Unicorns Rule" }; var snippet = new Footer(model, Server.MapPath("~/Views/Pdf/_Footer.cshtml"), 50, 5, 5, 10); generator.AddPageSnippet(snippet); var pdf = generator.GeneratePdf(GetModel(), Server.MapPath("~/Views/Pdf/ControllerlessPdfWithoutLayout.cshtml")); return(new FileContentResult(pdf, "application/pdf")); }
public ActionResult ControllerlessPdfWithLayout() { var generator = new StandaloneGenerator(new Parser(), Server.MapPath("~")) { Templates = new List <Template> { new Template { Name = "~/Views/Shared/_PdfLayout.cshtml", Source = System.IO.File.ReadAllText(Server.MapPath("~/Views/Shared/_PdfLayout.cshtml")) } } }; var pdf = generator.GeneratePdf(GetModel(), Server.MapPath("~/Views/Pdf/ControllerlessPdfWithLayout.cshtml")); return(new FileContentResult(pdf, "application/pdf")); }