cancel
Showing results for 
Search instead for 
Did you mean: 
trice602

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

 

canary1.png

 

Step #2: open up Canary and get through all the welcome screens and then closeClosing is important!  Next find canary and open the file location.

 

canary2.png

 

Step #3:  You want to copy the target path.  Then we will head over to Power Automate Desktop.

 

canary3.png

 

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.

 

headless1.png

 

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

 

trice602_1-1711598437773.png

 

 

Comments

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.

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.

 

 

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/ 

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/