Reputation: 79
I wanted to know how I can export the active slide on the presentation as a PDF. I was able to figure it out for google sheets but nothing for google slides.
Thank you!
Upvotes: 1
Views: 1479
Reputation: 201378
I believe your goal as follows.
For this, how about this answer? In this answer, I use the following flow.
Please copy and paste the following script to the container-bound script of Google Slides. And, please open a slide in the Google Slide and run this script. By this, the PDF file of the active slide is created in the folder of destinationFolderId
.
function myFunction() {
const destinationFolderId = "###"; // Please set the destination folder ID.
// 1. Retrieve the active slide.
const s = SlidesApp.getActivePresentation();
const activeSlide = s.getSelection().getCurrentPage().asSlide();
// 2. Create a temporal Google Slides.
const temporalSlides = SlidesApp.create("temporalSlides");
// 3. Copy the active slide to the temporal Google Slides.
temporalSlides.insertSlide(0, activeSlide);
// 4. Delete the initial slide in the temporal Google Slides.
temporalSlides.getSlides()[1].remove();
temporalSlides.saveAndClose();
// 5. Export the temporal Google Slides as a PDF file.
const file = DriveApp.getFileById(temporalSlides.getId());
DriveApp.getFolderById(destinationFolderId).createFile(file.getBlob().setName(`${s.getName()}.pdf`));
// 6. Delete the temporal Google Slides.
file.setTrashed(true);
}
Upvotes: 1