I know that when you manually copy and paste a slide from GSlides to GDocs, there is an option to 'Link to presentation', which allows the pasted image/object in GDocs to remain linked to the original presentation. When the original presentation is updated, a 'Refresh' button appears on the linked object in GDocs, and clicking it syncs the object with the original slide. However, doing this for a big presentation with dozens/hundreds of slides is tedious and time-consuming, so I am trying to write a script in GSlides, which automates copying and pasting linked thumbnails of slides into a GDocs file.
I have found a way to get an image of the thumbnail from GSlides to a GDocs file using Apps Script, but this thumbnail remains as a static image, and there is no way to 're-sync' it to reflect future changes in the presentation. I have also tried programmatically setting a 'LinkUrl' for the pasted image, and setting this Url to the Url which points to the exact slide which the image corresponds to, but this is not the same as manually pasting the slide in, and doesn't link it in the same way - the image still remains static.
This is my Apps Script code which does what I've described above:
function exportSlideImages(presentationId) {
let presentation = SlidesApp.openById(presentationId);
let doc = DocumentApp.create('Synced doc');
presentation.getSlides().forEach(function(slide, i) {
let thumbnail = Slides.Presentations.Pages.getThumbnail(presentationId, slide.getObjectId(), {
'thumbnailProperties.thumbnailSize': 'SMALL'});
let response = UrlFetchApp.fetch(thumbnail.contentUrl);
let blob = response.getBlob();
blob.setName('slide' + (i + 1) + '.png');
let url = SlidesApp.getActivePresentation().getUrl();
let sldId = SlidesApp.getActivePresentation().getSlides()[i].getObjectId();
url = url + '/edit#slide=id.' + sldId;
doc.getBody().insertImage(i,blob).setLinkUrl(url);
});
}
function test() {
exportSlideImages(SlidesApp.getActivePresentation().getId())
}