Skip to content
BrianMinister edited this page Sep 4, 2014 · 1 revision

Rotativa wiki!

How to set properties for the ViewAsPDF function.

/*
 * So you know what filename is.
 */
string filename = "SomeFileName.pdf";

/*
 * So you know what inData is.
 */
List<string> inData = new List<string>  //Can be any marshalable object.

/* 
 * This is all inline, but you can create the view as an anonymous type, 
 * then populate its properties, then return it.
 */
return new ViewAsPdf("MyCSHtmlView", inData)
{ 
    FileName = filename,
    PageOrientation = Rotativa.Options.Orientation.Portrait ,
    IsGrayScale = true,
    IsJavaScriptDisabled = true,
    IsBackgroundDisabled = true,
    MinimumFontSize = 12,
    PageSize = Rotativa.Options.Size.Letter,
    PageMargins = new Rotativa.Options.Margins(15, 10, 15, 10),
    CustomSwitches = string.Format("--footer-left \"File Name: {0}\" "
    + "--footer-right \"Page [page] of [toPage]\" "
    + "--footer-font-size \"8\" "
    + "--footer-line " 
    + "--footer-spacing \"3\"", filename)
};
Clone this wiki locally