2017-04-05 93 views
0

我使用Rotativa资源从MVC ASP.NET项目的HTML页面创建PDF文件。这里是我的代码:将Rotativa HTML转换为ASP.NET MVC上的PDF:如何将PDF创建为景观?

控制器:

public class HomeController : Controller 
{ 
    public ActionResult Index() 
    { 
     return View(); 
    } 

    public ActionResult ExportPDF() 
    { 
     return new ActionAsPdf("Index") 
     { 
      FileName = Server.MapPath("~/Content/Relato.pdf") 
     }; 
    } 
} 

查看

<a href="@Url.Action("ExportPDF","Home")" class="hidden-print" >EXPORT PDF</a> 

正在创建的PDF文档是纵向布局。我怎样才能将它们设置为景观布局?

干杯!

回答

0

刚刚解决了这个问题。以下是更新后的代码(见PageOrientation和每页行):

public ActionResult ExportPDF() 
     { 
      return new ActionAsPdf("Index") 
      { 
       FileName = Server.MapPath("~/Content/Relato.pdf"), 
       PageOrientation = Rotativa.Options.Orientation.Landscape, 
       PageSize = Rotativa.Options.Size.A4 
      }; 
     } 

干杯!