How to Divide and Reassemble PDF Documents in Power Automate

Cloudmersive
5 min readDec 9, 2024

--

We’ve walked through the process of splitting and merging PDF documents in Power Automate on this blog — but we haven’t covered how those two actions can be used together in a single Power Automate flow.

After we divide a PDF into a series of separate documents, we can merge each page of the original document with a copy of another PDF document. This basic flow concept can be used to quickly create standardized reports, contracts, and other multipage PDF materials. It’s a great way to bypass the monotonous task of multipage PDF document assembly and disassembly.

Divide and Reassemble PDFs in Power Automate

In this article, we’ll walk through a basic example flow that demonstrates this PDF splitting and merging concept. We’ll use actions from the Cloudmersive Document Conversion connector actions list, so we’ll need a Cloudmersive API key (we can get one for free with 800 API calls/month and no commitments) to follow along.

We’ll start by creating a manually triggered instant cloud flow. This isn’t necessarily practical for a real-world production flow, but it’s the best way to test prospective connectors in Power Automate with full control over our inputs.

We’ll start by adding two Get file content actions to our flow.

The first action will pull a multi-page PDF document from our system, and the second will pull another PDF (this one can have one or more pages). Later on, we’ll merge the second document with each page from the original document.

In my example flow, I’ll be splitting a PDF that contains three separate data reports, and I’ll be merging each of those pages with a generic Lorem Ipsum document (we’ll imagine this document contains some standard information for clients or stakeholders to view along with their data).

In our next step, we’ll bring up the Cloudmersive Document Conversion connector in the Power Automate connector library.

Once we find it, we’ll click “See more” to view the full actions list.

To find our PDF splitting action, we’ll CTRL+F search the action title: Split a PDF file into separate PDF files, one per page.

Before we can being configuring our request, we’ll first need to create our Document Conversion connection. As mentioned earlier, we’ll need a Cloudmersive API key to authorize our connection, and we can get one for free on the Cloudmersive website.

To configure our request, we’ll enter our multi-page PDF file bytes into the initial parameter and then enter our file name (this can be any file name; it doesn’t have to be the original name) in the second parameter. We’ll then set our only Advanced parameter to “Yes” so the contents of our PDF document are returned directly to the flow as file bytes (and not as file URLs).

We’ll now navigate back to the Cloudmersive Document Conversion connector actions list and locate an action called Merge Two PDF Files Together.

After we select this action, we’ll enter dynamic content labeled DocumentContents (which contains the file bytes for each individual page in our original multipage PDF) in the initial Input File parameter, and we’ll enter our second PDF document contents in the next Input File parameter.

Since we’re dealing with an array of files, Power Automate will automatically wrap our Merge Two PDF Files action in a For each control. This ensures each page from the original multipage PDF document will merge with a copy of the second PDF document.

In the final step of our flow, we’ll use a Create file action within the For each control to generate our reassembled files and write them to a new SharePoint folder. We’ll use the PageNumber value from our Split PDF action to dynamically name each new document in this example.

We’ll now save our flow and run a test.

When our flow finishes running, we’ll find our reassembled documents in the folder we selected.

We can use this basic flow outline to reassemble PDF documents based on far more complex criteria than I’ve demonstrated in this example. We could, for example, reassemble our split PDF documents dynamically with other documents based on specific phrases, names, or numbers in the file.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet