How to Lock a PDF, Compress to ZIP Archive using Power Automate
If we’re planning on adding password-protection and encryption policies to a PDF, we might handle that in a dedicated PDF reader application. If we’re planning to compress that PDF into a ZIP archive too, however, we might find it easier to handle our entire end-to-end process in Power Automate.
In Power Automate, we can easily combine a series of separate file processing actions into a single workflow. In this case, we can secure a PDF and subsequently compress it to a ZIP archive via two quick steps in a manually triggered Instant cloud flow.
More specifically, we can use the Cloudmersive PDF and File Processing connectors in Power Automate to get the job done.
Lock and Compress a PDF in Power Automate
In the first step of our Instant cloud flow, we can add a file input field asking flow users to upload a PDF from their file system. We can also add text fields asking for User and Owner passwords.
In our next step, we can find the Cloudmersive PDF connector in the Power Automate connector library and locate the Encrypt and Password-Protect a PDF action.
After we select this action, we can create a connection for free with a free Cloudmersive API key.
To get a free API key, we can head to the Cloudmersive website and create a free account. This will give us 800 API calls per month with zero commitments, and we’ll be able to use this key for all Cloudmersive connectors in Power Automate.
We can then configure the file content & file name inputs in our request using dynamic content from our manual trigger.
Following that, we can open the Advanced parameters.
Here, we can set our User and Owner passwords using dynamic content from our manual trigger. We can also change the encryption algorithm to 128-bit RC4 if we’d like (I’d recommend leaving this field blank, however).
Now that we’ve locked our PDF with a password, we can compress it to a ZIP archive.
To do that, we can locate the Cloudmersive File Processing connector, select the Compress files to create a new zip archive action, and then create a connection using our free API key once again.
Since we’re only compressing one PDF file in this example, we can pass OutputContent from the Encrypt and Password-Protect a PDF action to the first file input field. We can then use the file name from our manual trigger step once again in the second field.
Finally, we can use the Create file action from the SharePoint connector to save our compressed & password-protected PDF file in a new folder.
When we select File Content in our Create file step, it’s important we remember to choose OutputContent from our Compress files action, not from our Encrypt and password-protect a PDF action (they appear very similar in the dynamic content window).
When we’re finished creating our new file, we can save our flow and set up a test.
After we select a PDF & enter our User and Owner password strings, we can run our flow and check SharePoint for our new compressed & protected PDF document.
When we unzip our file and attempt to open our PDF, we’ll find a password prompt in our web browser. Either of our two passwords will unlock the file for viewing.
In just a few quick steps, we’ve password-protected and compressed an important PDF document. We can reuse this flow AND we can expand it to include additional PDF documents.
Conclusion
In this article, we learned how to easily apply encryption & password-protection to a PDF and subsequently compress the PDF to a ZIP archive using Cloudmersive PDF and File Processing connectors in Power Automate.
We’ll cover more quick & easy Power Automate flows on this blog each day. Don’t forget to follow and check back in!