Webpage-to-PDF with Power Automate Desktop!
One of the key features of Power Automate Desktop is having the ability to work with webpage content. Common requests include the ability to create a pdf out of a webpage because maybe every end-user doesn't have access or a license, but you still need to send out a summary or a copy of a page. In today's age, it is very common to have a 3rd party system create reports that only a licensed user can see. Power automate can help and reproduce a webpage as a pdf in only 4 steps!
Step #1: download Google Chrome Canary here: Chrome Canary Features For Developers - Google Chrome
Step #2: open up Canary and get through all the welcome screens and then close! Closing is important! Next find canary and open the file location.
Step #3: You want to copy the target path. Then we will head over to Power Automate Desktop.
Step #4: In Power Automate Desktop, we will create a quick 4 step desktop flow. First, we will open a CMD session. Next, we use write to CMD session, add a delay, then close the CMD session.
The command is in this format:
In quotes, we paste in our target for the canary application followed by --headless=new
Next, we add --print-to-pdf="C:\Users\*****\Downloads\filename.pdf" or any place you want to create the file. Of course, the file naming convention can use dynamic content or variables, it's always your choice!
Lastly, we add the URL of the webpage we want to capture. So, in this example we create a pdf out of the homepage of the Power Automate Community Forums.
"C:\Users\thoma\AppData\Local\Google\Chrome SxS\Application\chrome.exe" --headless=new --print-to-pdf="C:\Users\thoma\Downloads\gheadless_test.pdf" https://powerusers.microsoft.com/t5/Microsoft-Power-Automate/ct-p/MPACommunity
And that's it! Just 4 steps! Here's a more valid use case to consider, imagine you have about 100 shipping reports you need to get out of a 3rd party system every night using your admin login and you want to create a pdf for each report, then save them to SharePoint to share with your team, upload them somewhere, and/or send them to others by email. With this scenario, you can easily feed your desktop flow a list of URLs and loop through them in the middle of the night, creating your pdf copies of your shipping reports.
Give Google headless a try for your next webpage-to-pdf automation project!
My name is Thomas Rice, aka trice602. If you have worked with me before, you know my tagline is.... "Always glad to help! Tom"
LinkedIn: Thomas Rice, PMP | LinkedIn
Comments
-
Webpage-to-PDF with Power Automate Desktop!
I found this page too late, but it's awesome to see there's a command-line switch for Chrome to immediately print-to-PDF, and headless too! A few weeks ago I did something similar in a hacky way, iterating through a one-column CSV text file with a URL on each row (one row per blog post I've published), and visit each row in a browser, send Ctrl+P keystroke (default printer is print to PDF), then fill out the Save dialog box with the title of the webpage. It worked "fine" but it wasn't robust. cmdrkeene.com/saving-my-entire-site-as-a-pdf-ebook/
-
Webpage-to-PDF with Power Automate Desktop!
Hi @PatrickMcLeanGL ,
I haven't tested this (but will try this weekend). Before writing to the CMD session, you can start a new Chrome session, navigate to the login page, login, then run your command. Again, not tested but have seen a few pages talk about it.
-
Webpage-to-PDF with Power Automate Desktop!
What if you have to visit a URL that requires authentication?
For example, I have a bunch of Salesforce URLs that lead to generated reports, that I want to have Power Automate go to and create a PDF of.
When I run your flow, I just get a capture of the login page.
*This post is locked for comments