After diving deep into automating Google Slides with Google Apps Script across “Phase 7: Google Slides Operations (Articles #61 to #75),” we have finally reached our grand finale (Article #75)!
Starting from Article #61, where we opened the “Sapporo Office Monthly Performance Report” template, we progressed through bulk text replacement (#62), dynamically duplicating slides (#63), inserting shapes, charts, and images (#64–#70), adding speaker notes (#73), and aligning elements (#74). You’ve developed serious skills to build presentations programmatically just the way you want.
But take a moment to reflect: Have you ever fully automated your slides with GAS, only to finish by manually clicking File > Download > PDF Document, downloading it to your local PC, and then dragging and dropping it into a shared folder?
It feels like such a missed opportunity when all that automated magic still leaves you with tedious manual chores at the very end!
That’s why today, we’re doing a comprehensive walkthrough of the essential method Presentation.getAs('application/pdf'). It instantly converts your completed Google Slides deck into a polished PDF, automatically saves it to Google Drive, and shares it with your stakeholders seamlessly!
While writing practical code to wrap up our monthly reporting workflow for the Sapporo office, we will break down the concept of “Blob”—a frequent hurdle for beginners—and cover practical auto-sharing techniques you can use on the job right away. Let’s power through this finale together!
1. What Is Presentation.getAs(‘application/pdf’) in the First Place?
Presentation.getAs('application/pdf') is a method used to convert and extract a Google Slides presentation (Presentation object) into a specified data format—in this case, PDF.
Breaking Down the Syntax
var pdfBlob = presentation.getAs('application/pdf');
presentation: The overall presentation object retrieved using methods likeSlidesApp.openById(), which we covered in Article #61..getAs(): An instruction meaning “retrieve as.” It converts (casts) the source into the specified data format.'application/pdf': A string specifying the target data format (MIME type). This tells GAS, “Please treat this presentation data as a PDF file!”
Why Should You Convert Presentations to PDF?
You might wonder, “Why not just share the Google Slides web link directly?” In business operations—especially for monthly reporting or external pitches—exporting to PDF offers huge advantages:
- Prevents broken layouts and missing fonts
It prevents font discrepancies and layout shifts across different devices, OS environments, or screen sizes, preserving 100% of your intended design. - Prevents accidental edits and tampering
It protects finalized monthly figures and confidential reports from unintended edits once distributed. - Far easier for printing, offline reading, and email attachments
PDF is the ideal, standard format for board meeting handouts, offline reviews without Wi-Fi, and formal email submissions.
💡 Looking Back: Do You Remember Article #60?
Do you recall converting invoice documents for the Sapporo office into PDFs in Article #60, the finale of the Google Docs series using Document.getAs('application/pdf')?
In Google Apps Script, whether you’re working with Docs or Slides, calling .getAs('application/pdf') to produce PDF data follows the exact same consistent rule. This architectural uniformity is one of the best parts of GAS!
2. The Key Concept: What Exactly Is a “Blob”?
To master getAs(), you simply cannot bypass the crucial concept of a “Blob”. Have you ever logged a variable to the console, seen Blob returned, and thought, “Wait, what on earth is a Blob?!”
Let’s use an easy analogy to make this super clear!
Think of It as a “Bucket of Raw Data”!
Spreadsheets, Slides, and images all exist in their own proprietary structures. When you run presentation.getAs('application/pdf'), GAS scans the visual content of the slides and converts it into a chunk of raw binary data structured as a PDF.
The bucket holding this chunk of raw binary data is what we call a Blob (Binary Large Object)!
[ Google Slides ] ──( getAs('application/pdf') )──> [ Blob (Bucket of PDF Data) ]
│
( DriveApp.createFile(blob) )
▼
[ PDF File on Google Drive ]
In other words, right after getAs() runs, the file does not yet exist on Google Drive. You are simply holding a bucket filled with PDF data (a Blob) in memory.
By following these two steps with this bucket (Blob):
- Label it with
.setName("Sapporo_Office_Monthly_Report.pdf") - Place it onto the Google Drive storage shelf using
DriveApp.createFile(blob)(from Article #42)
…it finally becomes a real PDF file that anyone can open in a browser or download to their computer!
3. STEP 1: Preparation! Create the “Sapporo Office Monthly Performance Report”
Let’s get our hands dirty and test this out with a live Google Slides deck and GAS!
Instructions
- Open Google Drive and create a new Google Slides presentation.
- Rename the file in the top-left corner to “Sapporo Office Monthly Performance Report_Original”.
- Add sample title text to the first slide like this:
- Title: Sapporo Office September 2026 Monthly Performance Report
- Subtitle: Sales Target 120% Achieved! / GAS Research Dept.
- Obtain the Presentation ID (File ID).
- Copy the Presentation ID directly from your browser’s address bar.
💡 How to Locate Your Presentation ID
The ID is the long alphanumeric string located between /d/ and /edit in your URL.
https://docs.google.com/presentation/d/ 1a2b3c4d5e6f… /edit
4. STEP 2: Hands-On! Automatically Convert Slides to PDF and Save to Drive
Now that your slide is ready, open the Apps Script editor. We’ll write a clean script that opens the slide, converts it to a PDF Blob, and creates a new PDF file right in the root folder of your Google Drive (My Drive).
1. Enter the Code
Open the script editor from your Google Sheet or create a standalone GAS project, then paste the following code (make sure to replace YOUR_PRESENTATION_ID with the ID you copied earlier):
function convertSlideToPdf() {
// 1. Specify the presentation ID and open the Google Slides deck (see Article #61)
var presentationId = "YOUR_PRESENTATION_ID"; // ← Replace with your actual ID
var presentation = SlidesApp.openById(presentationId);
// 2. Convert the presentation into PDF data (Blob)
var pdfBlob = presentation.getAs('application/pdf');
// 3. Assign a clear, identifiable file name to the PDF Blob
pdfBlob.setName("[Confirmed] Sapporo Office Monthly Performance Report.pdf");
// 4. Create and save the new PDF file into My Drive (see Article #42)
var createdPdfFile = DriveApp.createFile(pdfBlob);
// 5. Output the execution results and file URL to the log (see Articles #1 & #49)
Logger.log("■ PDF auto-conversion completed successfully!");
Logger.log("■ Created file name: " + createdPdfFile.getName());
Logger.log("■ File view URL: " + createdPdfFile.getUrl());
}
2. Step-by-Step Code Walkthrough
Let’s review exactly what happens on each line:
var presentation = SlidesApp.openById(presentationId);- As introduced in Article #61, this loads the specified Google Slides document into our GAS execution environment.
var pdfBlob = presentation.getAs('application/pdf');- The star of the show today! Calling
.getAs('application/pdf')takes the entire presentation and packages all slide layouts and visual styling into a PDF data blob.
- The star of the show today! Calling
pdfBlob.setName("[Confirmed] Sapporo Office Monthly Performance Report.pdf");- We set the filename for the resulting PDF on the Blob using
.setName(). Always remember to append the.pdfextension at the end!
- We set the filename for the resulting PDF on the Blob using
var createdPdfFile = DriveApp.createFile(pdfBlob);- From Article #42 on
DriveApp.createFile(). By passing our PDF Blob, GAS writes the physical PDF file directly into your Google Drive root.
- From Article #42 on
3. Authorizing the Script for the First Run
Click Save (the disk icon) in the editor toolbar, then click Run.
Because this script uses DriveApp (file management) alongside SlidesApp, Google will prompt you with an authorization modal on the initial execution (see Article #2).
3-Step Authorization Process
- Click Review permissions when the modal appears.
- Select the Google account you are currently using.
- When the warning “Google hasn’t verified this app” appears, click Advanced in the bottom-left > Go to Untitled project (unsafe) > Allow.
4. Verify the Execution Logs
Once authorized, your script will execute. Take a look at the Execution log at the bottom of the editor:
Info ■ PDF auto-conversion completed successfully!
Info ■ Created file name: [Confirmed] Sapporo Office Monthly Performance Report.pdf
Info ■ File view URL: https://drive.google.com/file/d/1xxxxxxxxx/view?usp=drivesdk
Open your Google Drive (My Drive), and you’ll find “[Confirmed] Sapporo Office Monthly Performance Report.pdf” newly created! Double-click it to verify that your slide elements converted cleanly into PDF format.
5. STEP 3: Real-World Applications: 3 Advanced Patterns for PDF Generation
Simply saving to My Drive is great, but production workflows demand a bit more polish. Here are 3 practical patterns you can drop straight into your workplace systems!
Pattern 1: Automatically Embed the Execution Timestamp (e.g., 20260926) into the Filename
Outputting the same filename every time causes duplicate files to pile up, making file management messy. Using Utilities.formatDate() from Article #29, let’s dynamically append today’s date and time!
function convertPdfWithDate() {
var presentationId = "YOUR_PRESENTATION_ID";
var presentation = SlidesApp.openById(presentationId);
// Date formatting from Article #29! Generates a string like "20260226_1045"
var now = new Date();
var dateString = Utilities.formatDate(now, "JST", "yyyyMMdd_HHmm");
var pdfBlob = presentation.getAs('application/pdf');
// Set the dynamic filename containing the timestamp!
var fileName = "Sapporo_Office_Monthly_Performance_Report_" + dateString + ".pdf";
pdfBlob.setName(fileName);
DriveApp.createFile(pdfBlob);
Logger.log("Created timestamped PDF: " + fileName);
}
Now each execution creates a uniquely named file like “Sapporo_Office_Monthly_Performance_Report_20260226_1045.pdf”, making log reviews and file organization effortless!
Pattern 2: Save directly into a Dedicated Google Drive Folder
To prevent clutter in the root of My Drive, use DriveApp.getFolderById() from Article #41 to place the PDF inside a specific destination folder (such as “Monthly Reports”).
function savePdfToSpecificFolder() {
var presentationId = "YOUR_PRESENTATION_ID";
var folderId = "YOUR_FOLDER_ID"; // ← Specify your target Google Drive folder ID (Article #41)
var presentation = SlidesApp.openById(presentationId);
var pdfBlob = presentation.getAs('application/pdf');
pdfBlob.setName("Sapporo_Office_Monthly_Report_Latest.pdf");
// Retrieve the target folder and create the file inside it (Article #42)
var folder = DriveApp.getFolderById(folderId);
var pdfFile = folder.createFile(pdfBlob);
Logger.log("File saved to designated folder: " + pdfFile.getUrl());
}
Pattern 3: Automatically Email the PDF Attachment via Gmail!
Here is where GAS truly shines! You can take the generated PDF Blob and pass it directly to the attachments option of GmailApp.sendEmail() from Article #32.
The entire chain—”Update Slide Data ➡ Convert to PDF ➡ Dispatch Email to Team”—runs 100% autonomously without anyone lifting a finger!
function sendPdfByEmail() {
var presentationId = "YOUR_PRESENTATION_ID";
var presentation = SlidesApp.openById(presentationId);
// 1. Create the PDF data bucket (Blob)
var pdfBlob = presentation.getAs('application/pdf');
pdfBlob.setName("Sapporo_Office_Monthly_Performance_Report_Latest.pdf");
// 2. Set up email recipient, subject, and body
var recipient = "sapporo-team@example.com"; // Destination email address
var subject = "[Auto-Notification] Sapporo Office Monthly Performance Report (PDF)";
var body = "Hello Sapporo Team,\n\nHope you are having a productive week. Here is the automated delivery from the GAS Research Dept.\n\nThe monthly performance report (PDF) is ready and attached below.\n\nPlease review at your convenience.";
// 3. Send email with the attachment using GmailApp.sendEmail() from Article #32!
GmailApp.sendEmail(recipient, subject, body, {
attachments: [pdfBlob] // ← Simply pass the PDF Blob inside an array!
});
Logger.log("Email with PDF attachment sent successfully!");
}
6. Common Pitfalls: 4 Beginner Traps and How to Fix Them
When working with Presentation.getAs('application/pdf'), developers frequently run into a few common pitfalls. Let’s review these 4 gotchas so you can avoid debugging headaches!
Trap 1: Typo in the getAs() MIME Type Argument
Forgetting the slash or using invalid casing in application/pdf will break your script immediately.
- ✕
presentation.getAs('application-pdf')(Hyphen instead of slash) - ✕
presentation.getAs('pdf')(Only writing pdf) - ◯
presentation.getAs('application/pdf')(Correct MIME type)
💡 Pro Tip: Use the MimeType.PDF Constant!
Instead of typing raw strings, use the built-in MimeType.PDF constant provided by Google Apps Script to eliminate typos entirely.
// Using MimeType.PDF works identically to passing the string literal!
var pdfBlob = presentation.getAs(MimeType.PDF);
Because autocomplete works with constants in the editor, using MimeType.PDF is recommended by experienced engineers!
Trap 2: Exported PDF Ends Up Named “Untitled presentation.pdf”
Right after calling presentation.getAs('application/pdf'), the Blob inherits whatever name the original Google Slides deck has. If your source presentation is still called “Untitled presentation”, your exported PDF will be named “Untitled presentation.pdf”.
[Solution]
Get into the habit of always calling pdfBlob.setName("... .pdf") before saving to Drive so you give it a clear, descriptive name.
Trap 3: Slides Changed, but Latest Data Isn’t in the PDF?! (Sync Timing Trap)
If you dynamically modify text or elements using replaceAllText() (#62) or insertImage() (#70) and immediately call getAs('application/pdf'), the resulting PDF may occasionally contain outdated, pre-edit content.
This happens because GAS initiates the PDF rendering pipeline before all presentation edits have fully synced to Google’s backend servers.
[Solution] Commit Changes with saveAndClose()!
After executing heavy text replacements or element modifications, call presentation.saveAndClose() to flush all pending updates to the server. Then reopen the slide and run getAs() for guaranteed synchronization:
// Execute text substitutions...
presentation.replaceAllText("{TargetMonth}", "February 2026");
// Force-save all pending edits to Google servers and close!
presentation.saveAndClose();
// Reopen and convert to PDF reliably!
presentation = SlidesApp.openById(presentationId);
var pdfBlob = presentation.getAs(MimeType.PDF);
Trap 4: Scope Error: “DriveApp is not defined” or Permission Denied
When focusing solely on Slides manipulation (SlidesApp), developers sometimes forget that adding DriveApp calls requires updating project OAuth permissions.
As walked through in Step 2, ensure you approve Drive permissions during the initial authorization flow, or verify that your project manifest (appsscript.json) includes Drive authorization scopes.
7. Summary & Phase 7 Complete! What’s Next?
Today, we explored how to automatically convert Google Slides decks to PDF files, save them to Drive, and distribute them via email using Presentation.getAs('application/pdf').
Key Takeaways for Today
- Convert presentations to a PDF Blob (data bucket) using
presentation.getAs('application/pdf')orMimeType.PDF - Name your converted Blob clearly with
.setName("... .pdf") - Persist the Blob to Google Drive using
DriveApp.createFile(pdfBlob)orfolder.createFile(pdfBlob) - Attach the Blob directly into
GmailApp.sendEmail()‘sattachmentsproperty for instant email delivery - Call
saveAndClose()after batch edits to ensure all updates render accurately in the PDF
🎉 Celebrating the Completion of Phase 7 (Google Slides Automation)!
From Article #61 to #75, we spent 15 articles mastering Google Slides automation from the ground up. How does it feel?
You now possess a powerful engineering skillset: pulling real-time business metrics from Google Sheets or external APIs, populating Google Slides templates, aligning layout elements, appending speaker notes, rendering the finished slides as PDFs, and distributing them via email to your organization.
Our Sapporo office monthly reporting process is now 100% automated!
🚀 Next Up: Phase 8 “Google Calendar Integration” Begins!
Starting next time, we’re kicking off “Phase 8: Google Calendar Integration (Articles #76 to #80)”, an indispensable toolset for daily schedule management!
In milestone Article #76, we will dive into CalendarApp.getCalendarById()!
We’ll read meeting room reservation statuses across the Sapporo office, detect overlapping bookings, and take our first steps toward programmatic calendar management. Automating calendars is incredibly rewarding, so stay tuned!
