I need to import / copy some slides from one presentation to a new presentation using the slides API. After search a lot and don´t find nothing about it I ask you.
I use the Google Slides API. I use this code to get the slides of presentation A and do exactly the same to get the slides of other presentation B. I create a new presentation but I don´t know how to copy / set slides A and slides B into the new presentation.
May be the solution could be in the foreach loop execute some code like this
$pageElements = $slide->getPageElements();
$slide_new_presentation->setPageElements($pageElements);
but I don´t know the correct way to do it
// Get the API client and construct the service object.
$client = getClient();
$service_slides = new Google_Service_Slides($client);
$service_drive = new Google_Service_Drive($client);
/************************************
Create a new empty presentation
************************************/
$nueva_presentation = new Google_Service_Slides_Presentation(array(
'title' => utf8_encode('Name of the presetantion')
));
$nueva_presentation = $service_slides->presentations->create($nueva_presentation);
printf("Created presentation with ID: %s\n", $nueva_presentation->presentationId);
// Prints the number of slides and elements in a presentation
$presentationId = '1TCn0MLrjz05GrWTgcW3r5tRM4l4v9iy1gfunyQAB5kQ';
$presentation = $service_slides->presentations->get($presentationId);
$slides = $presentation->getSlides();
$pageElements = $slide->getPageElements();
printf("The presentation contains %s slides:\n", count($slides));
foreach ($slides as $i => $slide) {
// Print columns A and E, which correspond to indices 0 and 4.
printf("- Slide #%s contains %s elements.\n", $i + 1,
count($slide->getPageElements()));
$id_slide=$slide->getObjectId();
echo "<br>pageObjectId=".$id_slide;
}
// Prints the number of slides and elements in a presentation
$presentationId = '1fRz9_WgyfkWYMVkhL6Wox_BioE4C2pSQxKqhDw-GrkU';
$presentation = $service_slides->presentations->get($presentationId);
$slides = $presentation->getSlides();
$pageElements = $slide->getPageElements();
printf("The presentation contains %s slides:\n", count($slides));
foreach ($slides as $i => $slide) {
// Print columns A and E, which correspond to indices 0 and 4.
printf("- Slide #%s contains %s elements.\n", $i + 1,
count($slide->getPageElements()));
$id_slide=$slide->getObjectId();
echo "<br>pageObjectId=".$id_slide;
}