Automatically Save Google Doc as PDF on Edit

Saving on edit means a PDF is generated and saved every time the document changes. This is useful for live documents where stakeholders need an up-to-date PDF version available at all times.

The onEdit trigger

Saving on edit uses an installable onChange trigger in Apps Script rather than the simpler onEdit function. The installable trigger can call Drive API methods and UrlFetchApp, which the simple onEdit function cannot. In the Triggers panel, select your export function, set the event source to From Drive, and choose the On change event type.

Rate limits and performance

On a frequently edited document, an onEdit trigger that re-exports the entire document to PDF on every change can generate a large number of API calls. Consider adding a debounce by checking the last export time and skipping the export if it ran within the last five minutes. Store the timestamp in Script Properties.

Where the PDF is saved

Use DriveApp.createFile() to save the PDF to a specific Drive folder, or overwrite an existing file by deleting it first and creating a new one with the same name. Overwriting keeps a single current PDF rather than accumulating one per edit.

Frequently Asked Questions

Does the onEdit trigger work for documents I did not create?

The trigger runs as the user who installed it. It works on documents that user can access and export. The trigger does not require the document owner to install it.

Ready to Try It?

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

Install Free Extension