Our team has a need to implement some POCs around exporting MVC Views to PDFs, in hopes to come up with a shared library / service that we can then use to export a large number (100+) of Views to PDFs through the UI for our users. The MVC views that we're looking to export contain JavaScript that runs and makes ajax calls to pull certain parts of the form in a "lazy loading" type fashion, which causes some challenges with what we're looking to achieve here because we want to ensure all of the ajax calls are complete and the JavaScript is completely loaded / run before exporting the form to PDF.
This week I have been doing some research on any third party tools that could help us more easily export these MVC Views to PDFs:
Rotativa - In some other SO threads I saw this was a solid tool that is well known so I spent some time playing around with it. A challenge I had with Rotativa is that I wasn't able to get it to wait for the JavaScript / ajax calls to complete before creating the PDF.
Puppeteer Sharp - This is a C# Nuget package which interacts with Google's Puppeteer API to run Chromium commands in a headless fashion. I found that this tool can work by opening the page I'm looking to export in headless mode, waiting for a certain HTML selector to be available, and then exporting the page to PDF. My team has some concerns with the scalability of this for our use case, and we're not crazy about this code downloading Chromium to the server (this would eventually be hosted in an Azure App Service) in order to be able to run.
Aspose - Aspose is a tool that we have used in the past for PDF generation. This tool is something that we would leverage if we end up going with the new service / View route, specifically for this exporting functionality.
An approach that our team is starting to lean towards is creating a service which constructs a new View Model and View just for the sake of exporting, which obviously would take more time to develop and will increase maintenance down the road as now we have to maintain two different Views, one which is displayed on the web app for the user and one that is designed / styled just for PDF exporting.
Before starting to make any final decisions with our POCs I wanted to reach out here to see if anyone has had similar challenges and has a good, reliable tool that they leveraged to handle loading and exporting some more complex MVC Views to PDF?
Thank you for your help and any suggestions!