0

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;
    }
  • What library are you using? Or are you using some sort of Google HTTP API? Please edit a [mcve] into your question, so it is not put on hold. – halfer Oct 26 '17 at 12:08
  • Hey, I'm looking exactly the same! Did you find the solution for this? – MartinGian Nov 02 '17 at 17:34

0 Answers0