How To Convert an HTML Web Page To PDF Using Power Automate Desktop and FireFox |
Scroll Prev Top Next More |
The following flow shows how to convert an HTML web page to PDF using the Win2PDF printer and Mozilla FireFox.
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 Mozilla Firefox and the Win2PDF printer. This sample requires the Microsoft Power Automate for Firefox plug-in is installed.
WebAutomation.LaunchFirefox.LaunchFirefox Url: $'''https://helpdesk.win2pdf.com''' WindowState: WebAutomation.BrowserWindowState.Normal ClearCache: False ClearCookies: False 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