I have a slide presentation with charts linked to a spreadsheet. I want to create a PDF copy of all pages of this slide in one PDF file for distribution purposes. I found a script from @Tanaike which will work except for some additions.
- All slide pages must be copied in one PDF file.
- Must be able to select pages that needs to be copied as PDF.
- If possible please include a script to automatically email the PDF copy. Thank you very much in advance for any assistance.
Current Script:
function myFunction2() {
const folderId = "13Un85DDcMiW_ACHC1Tncrgaqt_DP5cg3"; // Please set the folder ID you want to put the exported PDF files.
// 1. Retrieve all slides from the source Google Slides.
const slide = SlidesApp.getActivePresentation();
const srcId = slide.getId();
const srcSlides = slide.getSlides();
// 2. Create a temporal Google Slides.
const file = DriveApp.getFileById(srcId).makeCopy("temp");
const id = file.getId();
let temp = SlidesApp.openById(id);
temp.getSlides().forEach((e, i) => {
if (i != 0) e.remove();
});
const folder = DriveApp.getFolderById(folderId);
// 3. Export each page as a PDF file.
srcSlides.forEach((s, i) => {
temp.appendSlide(s);
temp.getSlides()[0].remove();
temp.saveAndClose();
folder.createFile(file.getBlob().setName(`page_${i + 1}.pdf`));
temp = SlidesApp.openById(id);
});
// 4. Remove the temporal Google Slides.
file.setTrashed(true);
}