问题
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.
When I render the View, I see that jQuery is working, but when I render viewaspdf, the jquery is not working.
I have added --debug-javascript --no-stop-slow-scripts --javascript-delay 10000 but this looks to be not working. Can someone help me here?
Here is Controller detail:
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);
}
回答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
来源:https://stackoverflow.com/questions/47834906/rotativa-viewaspdf-not-executing-jquery