top of page
  • Writer's pictureYash Agarwal

Merge PDF with Power Automate and Win Automation

In this #PowerShot, I will show you how to setup a flow with Power Automate that calls a Win Automation process to merge two or more PDF documents. Currently, actions/ connectors that provide options to merge PDF documents are external and require additional subscription with the service providers.

Let's Get Started!

Merging multiple documents to one PDF is a common practice in many transaction/ business processes. For example, an email arrives with an Invoice of the ordered items and the order form separately. Once verified, both these documents need to be merged and sent in an email. Power Automate allows you to process individual documents, convert to PDF etc. with inbuilt and premium connectors. However, actions/ connectors that provide options to merge PDF documents are external and require additional subscription with the service providers. But, if you already have a license to run flows in Power Automate with Attended or Unattended RPA, you can use the actions from Win Automation to directly merge multiple PDFs to a single document.


Win Automation

Step 1: We will get the path of the PDF files to be merged from the main flow via command line arguments. Therefore, the first step in the process is to Get the Command Line Arguments.

Step 2: Search for PDF actions from actions and drag, drop the Merge PDF Files to the process. In this action, configure the input PDF files to be mapped to the command line arguments. Provide a path and a file name to temporarily store the merged PDF.


Power Automate

We will create a UI Flow to call the Win Automation process and then invoke the UI flow in a main flow.

UI Flow

Step 1: Create a UI Flow for a Desktop app and configure a simple text input. This input will contain the path of the temporarily created PDF files that have to be merged.

Step 2: Add the Run Win Automation action and provide the path of the process. In the Command Line Arguments property of this action, directly pass the inputs. Save and close the UI flow.


Step 1: Trigger- When an email arrives: To trigger the flow when a new email arrives with the subject "Merge PDF". Enable the Include Attachments and Only with Attachments properties in the action.

Step 2: Action- Initialize a variable: Initialize a variable of type array to store the path of the temporary PDF files that will be created in the file system.

Step 3: Control- Apply to each- To iterate over each attachment from the email and create a temporary PDF file.

//Loop Begins

Step 4: Action- Create File: Create a connection to the local file system using the File System connector and the On Premise Data Gateway (being used for the UI Flows). Add the action to create file and pass inputs from the dynamic selector to create files based on the attachments of the email.

Step 5: Action- Append to array variable: To store the path of the files created so that it can be later passed to the win automation workflow.

//Loop Ends

Step 6: Action- Compose: To join the file paths from the array to be sent to the win automation process. Expression: replace(join(variables('attachment path'),' '),'|','"')

Step 7: Action- Run a UI flow for desktop: To invoke the UI flow and run the Win Automation process. Pass the outputs of the compose action to the Paths property.

Step 8: Action- Get file content using path: To get the file content of the merged PDF created by the Win Automation process.

Step 9: Action- Delete file: To delete the temporarily created merged PDF file from the file system.

Step 10: Action- Send an email: To send an email to the requester with the merged PDF document. Pass the file content of the previous action and provide a name for the document.

Step 11: Control- Apply to each 2: To iterate over the files created for merging and delete them.

//Loop Starts

Step 12: Action- Delete File: To delete the temporarily created PDF files for merging. Expression: replace(items('Apply_to_each_2'),'|','')

//Loop ends


Setup in Action


In this post, we saw how to create temporary PDF files using the file system connector from Power Automate to merge them using a Win Automation process. Similar flows can be setup to create temporary PDF files from different sources via Power Automate and merged/ split/ text extracted etc. from a Win Automation Process and the outputs can be again used in Power Automate for further action.

I hope you found this interesting and it helped you. Thank you for reading!

Recent Posts

See All


bottom of page