Here is my approach to saving a webpage as a pdf using windows 10 pro and chrome. Use a start process activity to start headless chrome with arguments to save/print to pdf. It works pretty well and renders web pages as you would expect. I have read of issues with formatting using some approaches. If you have chrome installed, then no additional software installation is required. I found this approach more reliable than printing as pdf through the chrome user interface.
If your robot/app needs to enter values into a web page form prior to saving, I would consider entering those values and then saving the resultant html file (uses the windows save dialog which IMO is much more friendly to automation than the chrome print dialog). Then feed the html to the headless chrome.
Perhaps this is all easier with Internet Explorer or Edge, but I needed Chrome.
SavePDFofWebpageUsingHeadlessChrome.xaml (5.7 KB)
- Running headless chrome instances on my machine (Windows 10 pro) seemed to generate a lot of background chrome processes that were failing to close/exit. Then as I continued to use my robot to generate PDFs, the system would freeze after it had too many chrome instances (I think anyway). So I upgraded Chrome, after which nothing worked. This sent me down several rabbit holes. At the end of the day, I needed to update my chrome driver to match the updated chrome. After both Chrome and Chrome Driver were updated, I no longer had issues with chrome instances failing to exit. Prior to the updates, my system would freeze at about 20. I’ve tested the above with 60 separate instances with no issues.
- The approach above is I believe a low tech/ newb way to acheieve some of the functions of puppeteer.