Print the MVC page as a pdf plug-in Rotativa and mvcpdf plug-in rotativa
Recently, for a project, you need to print the user information page as pdf and export it. A plug-in was found on github, which is very useful.
Rotativa is an open-source dll encapsulation library for generating PDF documents on the user MVC page. We can find and install it in manage Nuget packages.
After installation, you can directly enter a view and generate a pdf file to return. The Code is as follows:
1 return new Rotativa.ActionAsPdf("UserInfo", new { id = id }) { FileName = "User.pdf" };
View Code
Rotativa. ActionAsPdf contains several overloaded constructors:
// Input an action name public ActionAsPdf (string action); // input the action name and the parameter public ActionAsPdf (string action, RouteValueDictionary routeValues) received by the key-value pair in the format of this action ); // input the action name and the object format parameter public ActionAsPdf (string action, object routeValues );
When the constructor instantiates the Rotativa. ActionAsPdf class, you can set some pdf generation information, such as FileName (pdf file name), UserName (adult), and Password.
Wkhtmltopdf 0.9.6 manuals: http://translate.baiducontent.com/transpage? Cb = translateCallback & ie = utf8 & source = url & query = http % 3A % 2F % 2Fmadalgo. au. dk % 2F ~ Jakobt%2fwkhtmltoxdoc%2fwkhtmltopdf9.9-doc.html & from = en & to = zh & token = & monLang = zh