Repeating Slides


In this tutorial, we will explain how to have a section of slides dynamically repeated based on the number of entries in an array.

Desired Output

This tutorial will focus on dynamically converting a single placeholder slide, which is a part of a PowerPoint template, into a collection of slides featuring similar information. Just like in the image below:

This image has an empty alt attribute; its file name is OverviewImage-2-1024x605.png

Sample Data

A data set containing information about recent hires can be found below:

{
   "NewEmployees":[
      {
         "name":"John Doe",
         "position":"Consultant",
         "startingdate":"April 15th",
         "photo_url":"https://images.pexels.com/photos/7710176/pexels-photo-7710176.jpeg?cs=srgb&dl=pexels-alena-darmel-7710176.jpg&fm=jpg",
         "answer1":"Having different challenges everyday, is my biggest source of motivation. Nothing beats the feeling of satisfaction one gets after having solved a tough case!",
         "answer2":"I have received the European Party Planner of the Year award twice, so I guess I can organize cool events :)"
      },
      {
         "name":"Sarah Bloggs",
         "position":"Developer",
         "startingdate":"April 1st",
         "photo_url":"https://images.pexels.com/photos/3201694/pexels-photo-3201694.jpeg?cs=srgb&dl=pexels-cottonbro-3201694.jpg&fm=jpg",
         "answer1":"My colleagues! Good cooperation is fundamental!",
         "answer2":"I play the banjo in a folk indie band. We have a couple of records out there and are planning our next tour soon!"
      },
      {
         "name":"Jane Doe",
         "position":"HR & Wellness Coordinator",
         "startingdate":"March 1st",
         "photo_url":"https://images.pexels.com/photos/2381069/pexels-photo-2381069.jpeg?cs=srgb&dl=pexels-emmy-e-2381069.jpg&fm=jpg",
         "answer1":"A good, productive, and friendly environment can really boost my motivation!",
         "answer2":"I used to be an elite chess player, but I am not playing currently. At the moment, I really enjoy gardening."
      }
   ]
}

In this particular scenario, the above data has been purposefully organized into an array of multiple objects, where each object stores the same kind of information (same keys, different values). This actually makes transforming the data unnecessary, as it is only needed to output it as is.

This image has an empty alt attribute; its file name is Sections-2.png

PowerPoint Template

The PowerPoint template used in this tutorial can be downloaded below. The template already contains all the needed bindings.

Section Bindings

Once the PowerPoint template is designed, the slides that will be repeated need to be organized in a separate section. Depending on the presentation, more sections might be required in order to control which slides are repeated. In this case, 3 sections will be needed: 1 for the title slide, one for the repeating slides, and one for the last slide (as seen in the image below).

Despite the other sections, the name of the section that will be repeated needs to be set to:

<<Repeat:Label$ArrayPath>>

where Label will be the name of the section in the final presentation that will be generated, and ArrayPath needs to be replaced with the JSON path of the array that the slide(s) will iterate upon. In this example, based on our data set which completely matches the output data, NewEmployees is the array path, and New Hires is the chosen label. This leads to the following binding:

<<Repeat:New Hires$NewEmployees>>

Field Bindings

The data set above contains a number of keys that hold information regarding each candidate. The purpose of this tutorial is to bind all of these in the slide that will be repeated. This can be achieved by using the following type of binding wherever it is needed:

<<Field:FieldName>>

In the binding above, FieldName needs to be replaced with the key that holds the information that needs to be displayed in that particular place. Keep in mind, that the FieldName parameter, as well as the ArrayPath above, are case sensitive. In the image below, the binding of the keys from this tutorial’s data set is demonstrated.

This image has an empty alt attribute; its file name is Bindings-1-1024x572.png

Picture Bindings

As it may be noticed, the “photo_url” key doesn’t seem to be bound anywhere in the image above. That is because images are bound in a different way. Firstly, a placeholder image needs to be present in the presentation. This will determine the size and ratio of the image that will be inserted in its place by DocuMotor. Then the corresponding key that holds an image URL is bound in the placeholder’s Alt Text, using the following binding:

<Image:AltText$ImagePath$FitType>>

where AltText will be the image’s Alt Text in the generated presentation, ImagePath is the JSON path that contains the image URL, and FitType controls how the image will fit the placeholder. FitType in particular can only be one of the following values:

FitFits the entire image within the bounds of the placeholder while keeping its aspect ratio.
FillFits the entire image into the entire placeholder shape, cropping out any of its parts that are outside the bounds of the shape.
StretchFits the entire image into the entire placeholder shape and changes its aspect ratio if necessary.  
RawFitFits the entire image within the bounds of the placeholder while keeping its aspect ratio and its original resolution.
RawFillFits the entire image into the entire placeholder shape, cropping out any of its parts that are outside the bounds of the shape and maintaining its original resolution.



It is possible to access the Alt Text pane by right-clicking on the placeholder image. As seen in the image below, in this case <<Image:Photot$photo_url$RawFill>> was used.

This image has an empty alt attribute; its file name is AltText.png

Result

Once the finalized template is uploaded to DocuMotor and the presentation is generated, the 3 slides below should appear in the section that was supposed to be repeated (and is now called New Hires).

This image has an empty alt attribute; its file name is Slides-1024x872.png