Merge and Combine PDF files using Power Automate

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

For this specific example we build a Flow that will Loop through all the PDF documents once a day in a OneDrive for Business Folder, merge them, and then create a merged PDF document in a different location of our choice.

It’s important to note that in this example we are combining 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 we begin please make sure the following prerequisites are in place:

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

Merging PDF using Power Automate (Flow Array Technique)

Here’s how to merge PDFs using Power Automate:

merge pdf with power automate

  1. Create a Scheduled Cloud Flow and then enter a suitable Flow Name, with a suitable Start Date and Start Time with a recurrence set to every day.

    create cloud flow

  2. Insert ‘Initialize variable’ Flow action to store the Merged Contents. Give this action a suitable name and set the fields as follows:
    Type: ‘String’
    Initial value: *Null

    variable flow action

  3. Insert ‘Initialize variable’ Flow action to store the Merged Count.

Type: “Integer”

Initial Value: Null

initialize variable flow

  1. Add the OneDrive for Business ‘List Files in folder’ Action on the Folder library which contains all the files that need to be Merged.

    list files in folder

  2. Insert the ‘Apply to Each Loop’ and add the Output(value) of ‘List Files in folder’ action.

apply to each loop

  1. Insert the ‘Add a condition’ action. Insert IsFolder is the Output of “List Files in folder” and you need to set it to “False”.

    add a condition action

  2. If the step above, evaluates to True, add the action ‘Get file content using path’

File Path: Path variable which is the output of ‘List Files in folder’.

file path

  1. Insert the ‘Add a condition’ action. Insert Merge Count is the Output of ‘Initialize variable – Merge Count’ and you need to set it to “0”.

    insert merge count

  2. If the step above, evaluates to True, add the Muhimbi ‘Convert Document Action’

The Action has two parameters:

Source File Name: Name is the output of ‘List Files in folder’.

Source File Content: File Content is the output of ‘Get file Content using Path’.

source file content

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

The action has three main parameters

Folder Path: The Path of your destination Folder.

File name: You can create a variable for File name if needed. We have hardcoded it to ‘MergedFile.PDF’.

File Content: Processed File Content is the output of ‘Convert Document’ action.

convert document

  1. Now, if the step 8 above, evaluates to False i.e. Merge Count is now not equal to 0, then add the action ‘Get file Content using Path’.

File Path : Enter the same path as in step 10.

file path

  1. Add the Muhimbi ‘Merge documents’ action. It has the following two main parameters

    Source File name -1: You can hardcode the File Name ‘MergedFile.pdf’ This file name should be the same as in step 10 and 11.

Source File Content -1: File Content is the output of ‘Get file Content using Path 2’ as in step 11.

Source File name -2: Name is the output of ‘List Files in folder’.

Source File Content -2: File Content is the output of ‘Get file Content using Path’ in step 8.

get file content using path

  1. Add the OneDrive for Business ‘Create file’ action, under step 12. The Action has three main parameters:

Folder Path: The path of your destination folder.

File name: We have hardcoded it to ‘MergedFile.PDF’.

File Content: Processed File Content is the output of ‘Merge Document’ action.

merge document

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

Name: Select the ‘Merged Count’ variable initialized in step 2.

Value: Set the Value to 1.

merge document workflow

You can test this workflow by setting the recurrence “Recurrence” Frequency to ‘Minute’. You can then upload a few PDF documents to the source location, and this will trigger the Flow after a minute and create the merged PDF document in the target.

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