Rotativa ViewAsPdf不执行jQuery [英] Rotativa ViewAsPdf not executing jquery
问题描述
我正在使用Rotativa(v1.6.4)将MVC视图转换为PDF.我已经在视图中使用jQuery来显示/隐藏某些文本内容.
I'm using Rotativa (v1.6.4) for converting an MVC view into a PDF. I have used jQuery in the View to show/hide certain text content.
当我渲染视图时,我看到jQuery在工作,但是当我渲染viewaspdf时,jQuery在工作.
When I render the View, I see that jQuery is working, but when I render viewaspdf, the jquery is not working.
我添加了--debug-javascript --no-stop-slow-scripts --javascript-delay 10000,但这似乎不起作用.有人可以帮我吗?
I have added --debug-javascript --no-stop-slow-scripts --javascript-delay 10000 but this looks to be not working. Can someone help me here?
这是控制器详细信息:
public ActionResult PrintBenificiaryForm()
{
PrintBenificiary p = new PrintBenificiary();
p.TeamMemberInfo = GetSessionValues();
p.IndividualBenefitPlans = GetBenefitPlansandIndividuals();
string customSwitches = string.Format("--debug-javascript --no-stop-slow-scripts --javascript-delay 10000 --footer-left \"[page] of [toPage]\" --footer-spacing -10 --footer-font-size \"10\" --header-html \"{0}\" ", Url.Action("PrintHeader", "Home", null, this.Request.Url.Scheme));
return new ViewAsPdf("PrintBenificiaryForm", p)// { FileName = p.TeamMemberInfo.FirstName + " " + p.TeamMemberInfo.LastName + ".pdf" };
{
CustomSwitches = customSwitches
};
//return View(p);
}
推荐答案
我遇到了同样的问题.我通过在"App_Browsers"文件夹中编辑"qt.browser"来解决此问题.它是由Rotativa在NuGet的安装包中创建的.我将name ="javascriptversion"的功能从1.7更改为我的jquery版本3.1.1.这就解决了我的问题.希望这对某人有帮助
I faced the same issue. I resolved this by editing 'qt.browser' in the 'App_Browsers' folder. It was created by Rotativa during the installing package from NuGet. I changed capability with name="javascriptversion" from 1.7 to my version of jquery - 3.1.1. And this resolved my issue. Hope this help someone
这篇关于Rotativa ViewAsPdf不执行jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!