Skip to content

Instantly share code, notes, and snippets.

@WiredUK
Created June 22, 2016 09:23
Show Gist options
  • Save WiredUK/695a3e9873dc3ebf2d42254f9844e133 to your computer and use it in GitHub Desktop.
Save WiredUK/695a3e9873dc3ebf2d42254f9844e133 to your computer and use it in GitHub Desktop.
Example code to output landscape PDF when using Wired.RazorPdf
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");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment