How to add password to PDF documents in Google Drive

Password protect PDF documents generated from Google Sheets. Add unique passwords to each PDF file and save them securely to Google Drive or send them as email attachments.

The Docs Studio add-on helps you create personalized PDF documents from Google Sheets. You can generate invoices, certificates, contracts, offer letters, student ID cards and other documents in bulk and save them to Google Drive.

Additionally, Document Studio now offers an option Protect generated PDF documents with a password.

This functionality is particularly valuable in scenarios where generated documents contain sensitive information that requires additional security to prevent unauthorized access. For example, you can generate invoices, or financial reports and protect them with a password before sharing them with clients or employees.

Add passwords to PDF documents

Let’s walk through the steps to add passwords to PDF documents generated from Google Sheets using Docs Studio.

Prepare salary data in Google Sheets

We have a google sheet which contains employee name and salary amount. We will use Document Studio to generate individual PDF pay slips for each employee and then add a password to each PDF document before saving it to Google Drive.

Create a template in Google Docs

We’ve created a pay slip template in a Google Doc that contains placeholders for the employee’s name and salary amount. Data from Google Sheets will be merged into this template to generate individual PDF documents for each employee.

Password protect PDF documents

Start Docs Studio in Google Sheets and create a new workflow. If you are new here, please refer to the step-by-step guide or watch this video tutorial to get started.

Within Workflow, select the Google Sheet that contains the employee data and the Google Docs template you’ve prepared for the payslips. Next, select the folder in Google Drive where the generated PDF documents will be saved.

Set the export format to PDF and enable it Password protected PDF Check box.

A unique password for each PDF document

You can use a common password for all PDF documents or, for added security, set a unique password for each document. For this example, we’ll define a unique password for each PDF document using the employee ID and the first four letters of the employee’s name, all in uppercase.

For example, if the employee ID is E345 and the name of the employee AngusThere will be a password for the corresponding PDF document E345ANGU.

We will use scriptlets to dynamically obtain a unique password for each PDF document.

{{ Employee ID }}{? "{{ Employee Name }}" | slice: 0,4 | upcase ?}

The above scriptlet appends the employee ID by converting the first four characters of the employee’s name, to uppercase.

Generate PDF documents

Save the workflow and run it to generate PDF payslips for all employees. The generated PDF documents will be saved in the specified Google Drive folder and each document will be protected by a unique password.

See also: Remove PDF password from Gmail attachments

Leave a Comment