2017-04-05 125 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 
      }; 
     } 

乾杯!