Protect a PDF document with a password in Power Automate

This Power Automate flow is based in one of our customers, a medical laboratory in Europe, used to inform Covid-19 PCR test results to the national health authority. The lab’s PDF reports contain sensitive information, and the health authority recommends them to be sent encrypted, which they do using PDF Blocks’ Add Password action.

The lab’s flow is triggered when a custom-built ERP generates the reports in PDF, which are then encrypted with the PDF Blocks’ Add Password action and posted to a secure FTP server. They use PDF Blocks’ European endpoint eu.api.pdfblocks.com to force the processing of the reports to be carried out on servers located within the European Union.

Trigger: Get the PDF file

Screenshot for When the Covid-19 report is generated

For this example, we replaced the original flow’s custom HTTP trigger with the When a file is created trigger in OneDrive for Business connector for Power Automate.

Rename the action to When the Covid-19 PCR report is generated.

Add password

Screenshot for Protect the report with a password

Use PDF Blocks’ Add Password action to protect the PDF report with a password. If this is your first time using PDF Blocks, sign up for a 14-day trial and create a connection.

The characters in a PDF password must be in the ASCII printable range (between positions 32 and 126). This range includes both lower and uppercase letters, numbers, space, and some commonly used symbols, such as: . , : ; # $ % & ( ) * + = ? !

Rename the action to Protect the report with a password.

Upload to FTP server

Screenshot for Upload to the health authority FTP server

Use the SFTP-SSH connector for Power Automate to transfer files to an FTP server via a secure SSH connection. The first time you use this connector, Power Automate will ask for the server address, the username, and password to set up a connection. Then use the Create file action to upload a file to the server.

Rename the action to Upload to the health authority’s FTP server.

Send an email notification

Screenshot for Notify compliance

To notify our compliance department each time a report is encrypted and uploaded to the health authority, use the Send an email notification in the Mail connector. You can also use Outlook, Gmail, or any other email provider with a Power Automate connector.

You can also add the encrypted report as an attachment, clicking Show advanced options and adding the Password Protected PDF File Content to the Attachment field and the trigger’s File name to the Attachment file name field.

Rename the action to Notify compliance.

The flow

The complete flow looks like this:

Full flow for Protect a PDF document with a password in Power Automate

Test the flow

To test the flow, just upload a PDF document to the /PCR Reports folder in OneDrive.

After the flow runs check that:

Adapt this example to your use case

If you need help adapting this example to fit your needs, contact us and we will be happy to help.

Last updated at 11 October 2020