Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotativa ViewAsPdf not executing 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.

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);
    }
like image 893
popat Avatar asked Jun 07 '26 15:06

popat


1 Answers

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

like image 55
Roma Stets Avatar answered Jun 10 '26 08:06

Roma Stets



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!