I’m using ASP.NET WEBFORMS and Telerik and I want to export a document with Telerik components. I’m doing this with client export manager of Telerik https://demos.telerik.com/aspnet-ajax/client-export-manager/overview/defaultcs.aspx, and it works, but I need to render the entire DOM, then show to user, then user clicks on EXPORT button, and if I have more than one document it can be tedious for the user, so I want to export document without this preview, exporting the documents without user interaction. At this moment, I have seen this possible options:
- Tried to export the DOM before showing to user (in Render() event for example) but I can’t execute this with JavaScript because the DOM is not fully rendered.
- Tried iText library, but this is not working with Telerik components (like graphics or grids)
The only thing on my mind right now is using something like https://phantomjs.org/ to automate the process where the user clicks the button automatically.
Could someone tell me any other strategy that does not require a lot of programming time?
Edit:I tried Selenium to simulate the user interaction, but obviously when the file is downloaded it is saved on external navigator, there is a way to save it on the user’s navigator?
2
Answers
Better way is to use jquery to print the entire page or the part of the document(HTML element).
As jquery wait DOM to render fully to run code.
Create a Javascript function to print the page/element and call that function when ever you want.
Customize above code as your requirement.
How to print HTML content on click of a button, but not the page?
https://www.geeksforgeeks.org/how-to-execute-jquery-code/#:~:text=The%20purpose%20of%20using%20jQuery,can%20be%20taken%20by%20jQuery.
I am not sure I follow your description 100%
But your DOM is for sure fully rendered after:
This Javascript snippet should allow you to do whatever you want after a complete page load:
put your export command after the alert.