Merge and Combine PDF Files Using Power Automate

In this guide, you’ll learn how to combine and merge multiple PDF files into a single PDF using Power Automate.

For this specific example, you'll build a flow that will loop through all the PDF documents in a OneDrive for Business folder once a day, merge them, and then create a merged PDF document in a different location of your choice.

This example combines PDFs in OneDrive, but you can easily merge multiple PDFs and save them to another destination like Dropbox, Google Drive, SharePoint, or any platform supported by Power Automate.

Prerequisites

Before beginning, ensure the following prerequisites are in place:

  • An Office 365 subscription with Power Automate and OneDrive for Business support.
  • A full or free trial subscription to Muhimbi’s PDF Converter for Power Automate.
  • Appropriate privileges to create flows.
  • Working knowledge of Microsoft Power Automate.

High-Level Overview

The image below shows a high-level overview of how to merge PDFs using Power Automate.

merge pdf with power automate

Merging PDFs Using Power Automate

First create a scheduled cloud flow and then enter a name in the Flow name field. Include the starting date and time, and set it to repeat every day. Press Create.

create cloud flow

Insert the Initialize variable flow action to store the merged contents. Give this action a suitable name, and set the Type field to String. Leave the Value field empty.

variable flow action

Insert the Initialize variable flow action to store the merged count. Set the Type field to Integer and leave the Value field empty.

initialize variable flow

Add the OneDrive for Business List files in folder action, and specify the path in the Folder field. This contains all the files that need to be merged.

list files in folder

Insert the Apply to each loop, and add the Output(value) of the List files in folder action.

apply to each loop

Insert the Add a condition action. Specify Is folder?, which is the output of the List files in folder action, and set it to false.

add a condition action

If the step above evaluates to true, add the Get file content using path action. In the File Path field, specify the Path variable, which is the output of the List files in folder action.

file path

Insert the Add a condition action. Insert Merged Count, which is the output of Initialize variable – Merged Count, and set it to 0.

insert merge count

If the step above evaluates to true, add the Muhimbi Convert document action.

The action has two parameters:

  • Source file name — The name is the output of the List files in folder action.
  • Source file contentFile content is the output of the Get file content using path action.

source file content

Insert the OneDrive for Business Create file action after the Convert document action.

The action has three main parameters:

  • Folder Path — This is the path of your destination folder.
  • File Name: You can create a variable for the file name, if needed. This example uses MergeFile.PDF.
  • File Content — This is Processed files content, which is the output of the Convert document action.

convert document

If the step above evaluates to false instead of true — i.e. Merged Count isn't equal to 0 — add the Get file content using path action. In the File Path field, specify the Path variable, which is the output of the List files in folder action.

get file content using path

Add the Muhimbi Merge documents action. It has the following parameters:

  • Source files name - 1 — You can hardcode the file name MergeFile.PDF. This file name should be the same as in previous steps.
  • Source files content - 1 — The file content is the output of the Get file content using path 2 action from earlier.
  • Source files name - 2 — Enter Name, which is the output of the List files in folder action.
  • Source files content - 2 — Enter Body, which is the output of the Get file content using path action.

merge document

Add the OneDrive for Business Create file 2 action. The action has three main parameters:

  • Folder Path — The path of your destination folder.
  • File Name — This is hardcoded to MergeFile.PDF.
  • File Content — This is Processed files content, which is the output of the Merge document action.

merge document workflow

Outside the Condition 2 action, add a Set variable action. The action has two main parameters:

  • Name — Select the Merged count variable from above.
  • Value — Set the Value field to 1.

You can test this workflow by setting the recurrence frequency at the beginning of the flow to Minute. Then, upload a few PDF documents to the source location, and this will trigger the flow and create the merged PDF document in the target destination.

Additional Resources

Have a Question?
We’re Always Happy to Help.

© Muhimbi Ltd. 2008 - 2024
This website uses cookies to ensure you get the best experience. Learn more