Export Google Docs as PDF Automatically with Apps Script

Using Apps Script to automatically export Google Docs as PDF gives you complete control over the workflow. The script exports the document, names the file, saves it to Drive, and optionally sends it by email.

Basic export function

The core of the script uses the Drive API to get the document by ID and fetch its PDF export URL. The response is saved as a file in Drive using DriveApp.createFile(). This function can be called manually or triggered on a schedule.

Adding a timestamp to the filename

To keep a history of exports, append the current date to the filename in the script. Use Utilities.formatDate(new Date(), 'GMT', 'yyyy-MM-dd') to get a formatted date string and concatenate it with the document name.

Running the script on multiple documents

To export an entire folder, use DriveApp.getFolderById() and iterate over its files. Check each file's MIME type to identify Google Docs, Sheets, and Slides, then export each one.

Frequently Asked Questions

Is Apps Script free to use for automated PDF exports?

Yes. Apps Script is included free with every Google account and has generous daily quotas for Drive operations.

Can I use Apps Script to export Google Sheets and Slides as PDF too?

Yes. The same approach works with different MIME types: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet for Sheets and application/pdf for Slides export.

Ready to Try It?

Install the free Chrome extension and start converting your Google Docs to PDF in one click.

Install Free Extension