I'm generating a pdf on Grails using the following pattern:
Optional Step: The user will choose either he wants to download the *.pdf or to open it on another tab, the default is to open it to another tab.
Main Step:
- Click the Generate Report button.
- The button will change its text to Generating Report, please wait...
It will run a block of JavaScript something like this:
var generate = "<sample url>" // some amazing processing goes here that appends data to the // query string. window.open(generate,'_blank');
Then it will open a new tab (or start downloading, depending on the option he had chosen).
Note: The opened tab is not an ordinary html markup, but rather a
*.pdf
that is rendered on a browser tab.- The tab (or the download) will load for at least five seconds to 1 minute or so.
- The pdf on that tab will finish loading and the user can now navigate the pdf (scroll down, save, print etc); or if it is a download, he can now open that file.
- The button on the calling tab will change its text to Report has been generated.
I already generated the reports successfully (both the new tab and the download approach), however my problem is I don't know how to detect if that tab has finished loading, and I cannot do step 7. Can anyone help me how to implement this?