The Microsoft Power Automate "Run DOS Command" action under the "System" menu allows you to call any Win2PDF Desktop command line option. You should start by entering the full path to the Win2PDF executable:
C:\Windows\System32\spool\drivers\x64\3\win2pdfd.exe on 64 bit editions or
C:\Windows\System32\spool\drivers\w32x86\3\win2pdfd.exe on 32 bit editions.
The Win2PDF Desktop command line options vary for each command. As an example, we'll use the "compress" command which takes a source file, compress ratio, and destination file as parameters. It's important to enclose all file name parameters in quote characters in case the file name paths include space characters.
As an example, we'll use the "Display select file dialog" to choose an existing PDF, and then split the file name using "Get file path part" so we can save the compressed PDF in the same location but with a different name.
The "Run DOS Command" action for the full command line for the compress command is:
C:\Windows\System32\spool\drivers\x64\3\win2pdfd.exe compress "%SelectedFile%" 50 "%Directory%%FileNameNoExtension%-compressed.pdf"
This opens a PDF, compresses it, and then saves it in the same folder with a "-compressed.pdf" added to the name.
To use this "flow", copy the following into a new Power Automate Desktop flow:
Display.SelectFile Title: $'''Compress PDF File''' FileFilter: $'''*.pdf''' IsTopMost: False CheckIfFileExists: True SelectedFile=> SelectedFile ButtonPressed=> ButtonPressed
File.GetPathPart File: SelectedFile RootPath=> RootPath Directory=> Directory FileName=> FileName FileNameWithoutExtension=> FileNameNoExtension Extension=> FileExtension
System.RunDOSCommand DOSCommandOrApplication: $'''C:\\Windows\\System32\\spool\\drivers\\x64\\3\\win2pdfd.exe compress \"%SelectedFile%\" 50 \"%Directory%\\%FileNameNoExtension%-compressed.pdf\"''' WorkingDirectory: $'''c:\\windows\\system32\\spool\\drivers\\x64\\3\\''' StandardOutput=> CommandOutput StandardError=> CommandErrorOutput ExitCode=> CommandExitCode
# Display result of compress command
Display.ShowMessage Title: $'''Win2PDF Compress''' Message: CommandOutput Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed2