How to make Rotativa wait for javascript/jquery execution
Asked Answered
C

3

6

I have a View that renders and some javascript/jquery that updates some fields. When I use Rotativa, it renders the view, but before the JS is executed to replace some field text.

Is there a way to delay Rotativa or have it wait for JS/JQuery?

Cranford answered 23/7, 2014 at 19:30 Comment(3)
Yeah, I'm kind of in the same spot. In my case, the Font Awesome CSS is not fully loading, so I get no icons. Until a better solution is found, I would advise you to check if you REALLY need Javascript. Can't you render the View with the fields already updated, instead of waiting for the front end (javascript) to do that job? Btw, how or where are you running that Javascript? Inside the document, at the end of the <body> tag? Or are you loading an external JS file?Zhukov
Fabio, I am using and External JS that is using the MVC Bundling. My JS functions update things on the Layout.cshtml as this site repsonds to various domain names etc. However, i did find a solution to my problem. I was using the Rotativa.ViewAsPdf() and this is where i was getting the problem. Are you using this method? if so try Rotative.ActionAsPdf() or Rotative.UrlAsPdf() as this rendered the full page as i expected after JavascriptCranford
Was there a final solution to this?Wheat
R
6

You should be able to delay pdf creation to wait for javascript to complete by setting this in Rotativa params:

CustomSwitches = "--no-stop-slow-scripts --javascript-delay 1000 "

Replace 1000 with the desired milliseconds.

Radnorshire answered 17/2, 2016 at 12:45 Comment(0)
W
1

I was facing same issue, and after so much googling and experiment my problem resolved by updating Rotativa to latest stable version as 1.6.4 using Manage Nuget Packages. May be it will help someone. Thanks.

Wesleyanism answered 18/9, 2017 at 7:31 Comment(0)
A
0

I had the same issue, we have a site using both ASP MVC for back-end and AngularJS for the front and couldn't get it it work, so created custom razor views for exporting. Was justifiable for this project to meet future client needs. but in other projects might have to look elsewhere for exporting.

Ashe answered 20/8, 2014 at 13:38 Comment(1)
Look at the KendoUI suite. I use a lot of Telerik Products and they have started implementing Export support for PDF and Excel into their controls. You can even use a MVC controller as a proxy as wellCranford

© 2022 - 2024 — McMap. All rights reserved.