我在先前的项目中成功使用了EVO HTML to PDF工具,现在我正尝试将其集成到另一个项目中。问题是我必须转换的页面在ASP.NET表单身份验证后面,当我转换页面时,我得到登录表单。如何通过表单身份验证并获取PDF中的页面内容?
您可以使用以下代码从当前请求中获取表单身份验证cookie,并将其传递给转换器,以便在访问要转换的HTML页面时使用:
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
// Add the Forms Authentication cookie to request
if (Request.Cookies[FormsAuthentication.FormsCookieName] != null)
{
htmlToPdfConverter.HttpRequestCookies.Add(FormsAuthentication.FormsCookieName,
Request.Cookies[FormsAuthentication.FormsCookieName].Value);
}
htmlToPdfConverter.ConvertUrl(urlToConvert);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句