MVC頁面列印成pdf外掛程式Rotativa

來源:互聯網
上載者:User

標籤:route   asp   file   封裝   block   name   userinfo   rac   檔案   

  最近做項目,需要把使用者資訊頁面列印成pdf匯出,在github上發現了一個外掛程式,非常好用。

  Rotativa是一個開源的使用者MVC頁面產生PDF格式文檔的dll封裝庫,我們可以在管理Nuget包中找到並安裝它。

  安裝好之後就可以直接輸入一個視圖,並產生pdf返回了,具體上代碼:

  

1 return new Rotativa.ActionAsPdf("UserInfo", new { id = id }) { FileName = "User.pdf" };
View Code

  Rotativa.ActionAsPdf包含幾種重載的建構函式:

//傳入一個action名稱public ActionAsPdf(string action);//傳入action名稱,和索引值對格式的此action接收的參數public ActionAsPdf(string action, RouteValueDictionary routeValues); //傳入action名稱,和object格式的參數public ActionAsPdf(string action, object routeValues);

  建構函式執行個體化Rotativa.ActionAsPdf類時可以設定一些pdf的產生資訊,例如FileName(pdf檔案名稱)、UserName(產生人)、Password(密碼)等資訊。

  

  

wkhtmltopdf 0.9.6手冊:http://translate.baiducontent.com/transpage?cb=translateCallback&ie=utf8&source=url&query=http%3A%2F%2Fmadalgo.au.dk%2F~jakobt%2Fwkhtmltoxdoc%2Fwkhtmltopdf-0.9.9-doc.html&from=en&to=zh&token=&monLang=zh

MVC頁面列印成pdf外掛程式Rotativa

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.