I'm using Rotativa resources to create PDF files from my HTML page on an MVC ASP.NET project. Here is my code:
Controller:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult ExportPDF()
{
return new ActionAsPdf("Index")
{
FileName = Server.MapPath("~/Content/Relato.pdf")
};
}
}
View
<a href="@Url.Action("ExportPDF","Home")" class="hidden-print" >EXPORT PDF</a>
The PDF documents being created are in portrait layout. How could I set them into landscape layout?
Cheers!
Just solved the issue. Here is the updated code (See PageOrientation and PageSize lines):
public ActionResult ExportPDF()
{
return new ActionAsPdf("Index")
{
FileName = Server.MapPath("~/Content/Relato.pdf"),
PageOrientation = Rotativa.Options.Orientation.Landscape,
PageSize = Rotativa.Options.Size.A4
};
}
Cheers!