How to Unlock and Decrypt a Password-Protected PDF in Power Automate

Cloudmersive
4 min readOct 7, 2024

--

Processing and editing PDF documents in Power Automate is simple enough when those files are open and accessible to anyone.

What happens, though, when we build flows involving encrypted and password protected PDFs?

When we deal with secured PDFs, we’ll need to unlock and decrypt them before we can make meaningful changes to their contents in a Power Automate flow. Thankfully, there’s an easy way to do that.

Using the Cloudmersive PDF connector in Power Automate, we can programmatically supply the password for a PDF document to unlock it (this depends, of course, on our having access to the password), and we can automatically remove encryption measures thereafter. We’ll end up with the PDF file bytes we need to perform automated PDF file editing operations in our flow.

Walkthrough

To demonstrate this PDF decryption workflow, we’ll set up a manually triggered instant cloud flow. We’ll load a PDF into our flow and set up the action we need to unlock it as a quick context-free demonstration of its capabilities.

We’ll start by adding a Get file content action to retrieve our encrypted, password-protected PDF file bytes.

After that, we’ll add in our Cloudmersive PDF connector action.

To find this action, we’ll add a new action and type “Cloudmersive” into the search bar. This brings up a list of several Cloudmersive connectors; we’ll find the Cloudmersive PDF connector on this list with a pink logo.

After we click “See more” to view the actions list, we’ll find the Decrypt and password-protect action we’re looking for near the top of the list.

In order to use this action in our flow, we’ll first need to create our connection with a Cloudmersive API key. We can get a free API key by visiting the Cloudmersive website and creating a free account (this allows a limit of 800 API calls per month with zero commitments). When we set up our connection this way, we make secure API calls against Cloudmersive’s public cloud infrastructure.

To configure our PDF decryption and password removal request, we’ll supply our password value in the first parameter, and we’ll then provide the PDF file bytes and file name in the second two parameters.

The password we use to unlock the document can be either the owner or reader password. I’ve used the owner password for my example document.

This action returns a decrypted PDF to our flow with password protection removed from the document. We can take a variety of next steps with that content depending on our use-case; in this example, we’ll convert our PDF to MS Word (DOCX) using the Cloudmersive Document Conversion connector and save that document in a new folder.

After we save and test our flow, we’ll find our converted PDF document in our target folder.

Based on how we’ve constructed this flow, our original PDF will remain encrypted and password-protected in its original folder. If we want to overwrite that file with the decrypted and unlocked version, we can add an Update file action to our flow and use response content from the Decrypt and password-protect a PDF action to replace the original content.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet