appscript.dev
Automation Beginner Slides Drive

Build a Slide-to-PDF handout generator

Export a clean, notes-included PDF of a Northwind deck for handouts.

Published Oct 19, 2025

Northwind runs client workshops, and every workshop ends with the same small chore — turning the slide deck into a PDF handout and dropping it in the shared folder. File → Download → PDF does the job, but it lands the file in Downloads, where it has to be renamed and moved by hand. Done a dozen times a month, that adds up.

This script removes the manual steps. Given a deck and a destination folder, it exports the deck as a PDF, names it after the deck, and saves it straight into the folder. It is the simplest automation in the Slides set, and a good building block for any “make a PDF and file it” workflow.

What you’ll need

  • The file ID of the Google Slides deck to export — the long string in the deck’s URL.
  • The folder ID of the Drive folder where the handout should be saved.
  • Edit access to that folder, so the script can create files in it.

The script

// The deck to export and the folder the PDF should land in.
const DECK_ID = '1abcDeckId';
const OUTPUT_FOLDER_ID = '1abcFolderId';

/**
 * Exports a Slides deck as a PDF and saves it into a Drive folder,
 * named after the deck itself.
 */
function deckToPdf(deckId, outputFolderId) {
  // Fall back to the configured IDs when called with no arguments.
  deckId = deckId || DECK_ID;
  outputFolderId = outputFolderId || OUTPUT_FOLDER_ID;

  // Get the deck as a Drive file and render it to a PDF blob.
  const file = DriveApp.getFileById(deckId);
  const pdf = file.getAs('application/pdf')
    .setName(`${file.getName()}.pdf`);

  // Create the PDF in the target folder and log where it landed.
  const saved = DriveApp.getFolderById(outputFolderId).createFile(pdf);
  Logger.log('Saved handout: ' + saved.getUrl());
}

How it works

  1. deckToPdf accepts a deck ID and a folder ID, but falls back to the DECK_ID and OUTPUT_FOLDER_ID constants when run with no arguments — so it works both from the editor and as a reusable helper.
  2. It fetches the deck as a Drive file with getFileById. A Slides deck is a Drive file, so DriveApp can read it directly.
  3. getAs('application/pdf') asks Drive to render the deck into a PDF blob — this is the same export Drive performs when you download a deck as a PDF.
  4. setName names the blob after the deck, with a .pdf extension, so the handout is easy to recognise.
  5. createFile writes the blob into the destination folder, and the script logs the new file’s URL so you can click straight through to it.

Example run

With a deck called “Q2 Client Workshop” and a “Handouts” folder, running deckToPdf produces:

BeforeAfter
Deck “Q2 Client Workshop” in SlidesSame deck, untouched
”Handouts” folder empty”Handouts” folder contains “Q2 Client Workshop.pdf”

The log shows a line like Saved handout: https://drive.google.com/file/d/.../view, a direct link to the new PDF.

Run it

This is an on-demand job — run it whenever a handout is needed:

  1. In the Apps Script editor, set DECK_ID and OUTPUT_FOLDER_ID to your deck and folder.
  2. Select deckToPdf and click Run.
  3. Approve the authorisation prompt the first time.
  4. Open the destination folder, or click the logged link, to find the PDF.

Watch out for

  • The PDF export does not include speaker notes. getAs('application/pdf') renders the slides only. For a notes-included handout, fetch the Slides export URL with format=pdf per slide and assemble the pages, or copy the deck into a Doc layout first.
  • Running the script twice creates a second file with the same name — Drive allows duplicate names. Delete or overwrite the old PDF if you need just one.
  • getAs renders the deck at its current state. Make sure every placeholder is filled before exporting, or the handout will show raw {{tokens}}.
  • Very large decks can take a while to render and may approach the script execution time limit. For long decks, run the export on its own rather than inside a bigger batch job.
  • The script needs edit access to the destination folder. A view-only folder will throw a permissions error on createFile.

Related