Please enable JavaScript to view this site.

Navigation: How To Articles > How to Automate Win2PDF with Microsoft Power Automate Desktop > Win2PDF Power Automate Desktop Example Flows

How To Convert an HTML Web Page To PDF Using Power Automate Desktop and Google Chrome

Scroll Prev Top Next More

The following flow shows how to convert an HTML web page to PDF using the Win2PDF printer and Google Chrome.

 

power-automate-desktop-html-to-pdf-chrome-flow

 

To use this "flow", copy the following into a new Power Automate Desktop flow:

 

# This Power Automate Desktop flow converts an HTML file to PDF using Google Chrome and the Win2PDF printer. This sample requires the Microsoft Power Automate for Chrome plug-in is installed.

WebAutomation.LaunchChrome.LaunchChrome Url: $'''https://helpdesk.win2pdf.com''' WindowState: WebAutomation.BrowserWindowState.Normal ClearCache: False ClearCookies: False Timeout: 60 BrowserInstance=> Browser

File.GetTempPath TempFile=> TempFile

WebAutomation.TakeScreenshot.TakeScreenshotSaveToFile BrowserInstance: Browser File: TempFile FileFormat: WebAutomation.FileFormat.Png

/# Convert the PNG to PDF using the Win2PDF Desktop Command Line

C:\\Windows\\System32\\spool\\drivers\\x64\\3\\win2pdfd png2pdf %TempFile% %TempFile%.pdf#/

Scripting.RunDOSCommand.RunDOSCommand DOSCommandOrApplication: $'''C:\\Windows\\System32\\spool\\drivers\\x64\\3\\win2pdfd png2pdf %TempFile% %TempFile%.pdf''' StandardOutput=> CommandOutput StandardError=> CommandErrorOutput ExitCode=> CommandExitCode

/# Make the PDF searchable (optional)

Requires the Win2PDF OCR Add-on download

C:\\Windows\\System32\\spool\\drivers\\x64\\3\\win2pdfd.exe makesearchable %TempFile%.pdf %TempFile%.pdf#/

Scripting.RunDOSCommand.RunDOSCommand DOSCommandOrApplication: $'''C:\\Windows\\System32\\spool\\drivers\\x64\\3\\win2pdfd.exe makesearchable %TempFile%.pdf %TempFile%.pdf''' StandardOutput=> CommandOutput2 StandardError=> CommandErrorOutput2 ExitCode=> CommandExitCode2

# Delete the temporary PNG file

File.Delete Files: TempFile

WebAutomation.CloseWebBrowser BrowserInstance: Browser

# Open the PDF using the default viewer

System.RunApplication.RunApplication ApplicationPath: $'''%TempFile%.pdf''' WindowStyle: System.ProcessWindowStyle.Normal ProcessId=> AppProcessId