この Rotativa 1.6.4 コード例を使用して、.NET MVC 5 アプリのページから PDF を生成していました。
public ActionResult PrintIndex()
{
var a = new ActionAsPdf("Index", new { name = "Giorgio" }) { FileName = "Test.pdf" };
a.Cookies = Request.Cookies.AllKeys.ToDictionary(k => k, k => Request.Cookies[k].Value);
a.FormsAuthenticationCookieName = System.Web.Security.FormsAuthentication.FormsCookieName;
a.CustomSwitches = "--load-error-handling ignore";
return a;
}
public ActionResult Index(string name)
{
ViewBag.Message = string.Format("Hello {0} to ASP.NET MVC!", name);
return View();
}
インデックス ページを印刷していたのではなく、ログイン ページを印刷していました。
認証の問題を修正したら、.pdf を使用しても PDF の生成が非常に遅くなりましたCustomSwitches
。(数分)
上記のコードは実際に機能する可能性がありCookies
ます。プロパティを使用して認証の問題を回避しましたが、私には遅すぎました。
安全なページをすばやく印刷するにはどうすればよいですか?