How to Remove Pages from a PDF Document in Power Automate

Cloudmersive
5 min readOct 24, 2024

--

Larger PDF documents — especially official documents like contracts and depositions — generally exist in a constant state of flux. As circumstances evolve in a negotiation or legal process, relevant documentation is added and removed from important files, with the end goal being a finalized, compliant document that can be archived and referred to as needed in the future.

Automating PDF Page Removal

Given how Power Automate connects so many important applications in our Microsoft ecosystem (and beyond), it’s a great platform for automating persistent document-driven workflows like the ones described above. Not only can we automate the removal of pages from important PDFs, but we can tie the results of those workflows directly into subsequent emails and approvals, ensuring we solicit feedback from stakeholders after taking actions on an important file.

Walkthrough: Remove PDF Pages in Power Automate

In this quick Power Automate walkthrough, we’ll learn one simple & easy way to delete pages from a PDF document, and as part of our use-case demo, we’ll send the results of that workflow to a “stakeholder” in an Approval message. We’ll be able to easily build upon this flow by taking additional steps post-approval in production scenarios.

To start, we’ll select the option to build a manually triggered, instant cloud flow. This option is best for demos & testing scenarios.

We’ll start by retrieving a multi-page PDF document from our file system. We can use a Get file content action from either the SharePoint or OneDrive connectors for this purpose. In my example, I’m using a simple four-page PDF containing Lorem Ipsum text content.

Next, we’ll open a new action and search for “Cloudmersive” connectors. We’re looking for the Cloudmersive PDF connector, which has a pink logo.

To view the actions list, we’ll click “See more”, and from there we’ll search for an action aptly labeled Remove, delete pages from a PDF document.

We’ll notice the “Premium” tag next to these connector actions. That means we’ll need a premium Power Automate license to access these actions — but we can use them for free (as I am in this demo) up to 800 API calls/month with a free API key. We can get one of those by creating a free account on the Cloudmersive website.

To configure our PDF page removal request, we’ll start by adding our file bytes and file name (this can be any made-up name) in the initial two parameters.

Right after that, we’ll find two parameters asking for the page numbers to start and stop deleting from. PDF pages are 1-based, and the count here is inclusive, so if we enter “2, 2” as I’ve done below, we’ll delete ONLY the second page of our document.

Now that we’ve handled our page removal request, we’ll share our document with a “stakeholder” in an Approval message. We want this “stakdeholder” to check that they’re ok with the adjusted document contents; once they’ve confirmed that’s the case, their response message will trigger any subsequent steps we decide to add to our flow.

In my example, I’m using the Start and wait for an approval action, and I’m selecting the Approve/Reject — First to respond approval type.

Regardless of which approval type we choose, we’ll attach our document the same way — by opening the advanced parameters and creating a new Attachments item. Within this item, we’ll add OutputContent from the Remove, delete pages action, and we’ll name our file however we’d like (as a quick aside — if we’re interested in dynamically reusing the original file name, we can use a Get file metadata action at the beginning of our flow).

We’ll now save and run our flow.

We’ll notice that our Start and wait for an approval action remains in limbo after the other actions complete their tasks.

In my example, I sent the approval message to myself, and it’s waiting for me in my Outlook inbox with the PDF attached.

I can now review the document, ensure the correct pages are removed, and click Approve to execute the rest of the flow.

When I check back in on my flow, I’ll notice the approval finished running. Any actions placed after this approval would now run — such as, for example, an Outlook Email action sharing the document with a client or customer.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet