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?

Dave Miller
  • 536
  • 3
  • 19
Loren.Dorez
  • 605
  • 1
  • 8
  • 11
  • 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 tag? Or are you loading an external JS file? – Fábio Duque Silva Jul 24 '14 at 13:08
  • 2
    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 Javascript – Loren.Dorez Jul 25 '14 at 15:10
  • Was there a final solution to this? – Vin Shahrdar Aug 14 '19 at 13:37

3 Answers3

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.

Giorgio Bozio
  • 2,982
  • 3
  • 20
  • 20
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.

RP Nainwal
  • 305
  • 5
  • 8
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.

Jon D
  • 254
  • 1
  • 10
  • 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 well – Loren.Dorez May 05 '15 at 22:16