Export Google Docs as PDF to Google Drive Using Apps Script
Exporting using Apps Script gives you full automation control. Write the script once and it runs on any schedule, saving PDFs to any folder, with any naming convention, without human involvement.
Basic export script structure
A minimal Apps Script for exporting a Google Doc to PDF in Drive is straightforward: get the file by ID, export it as a PDF blob, create a new file in the target folder with the blob, and optionally log the result. Add error handling to catch permission issues or API errors.
Iterating over a folder
To export all documents in a folder, use DriveApp.getFolderById() to get the folder, then iterate over its files with getFiles(). For each file that is a Google Doc, Sheets, or Slides file, run the export and save to the target folder.
Setting up a trigger
In the Apps Script editor, go to Triggers (the clock icon), create a new trigger for your function, and set it to run on a time-based schedule. The script runs on Google's servers at the specified time, even if your computer is off.
Frequently Asked Questions
Do I need to be a developer to use Apps Script for PDF exports?
Basic JavaScript knowledge is enough. The Apps Script editor is in your browser and Google's documentation has copy-paste examples for common Drive operations.
Is Apps Script free to use?
Yes. Google Apps Script is included with every Google account and Google Workspace subscription.
Ready to Try It?
Install the free Chrome extension and start converting your Google Docs to PDF in one click.
Install Free Extension