Pictures in PPTX templates

This article shows how to use the picture formatter to dynamically insert pictures into PPTX documents.

Prepare PPTX template

There are some steps you need to do to use the piсture tag. Let’s take a look.

Insert a placeholder picture into your PPTX template. This placeholder will be replaced with a real picture in the final document.

Picture

Then place the picture tag into AltText section of the placeholder picture.

{{imageData}:picture}
Picture

The formatter accepts URLs. The URL must be publicly anonymously available (no authentication).

Library

For the template from the picture above to work you need to use JSON object like this:

{
    "imageData": "https://plumsail.com/docs/documents/v1.x/_images/plumsail-logo.png"
}

Also, the formatter supports Base64 strings as pictures. Thus, for the template from the picture above to work you will need to pass something like this:

Library
{
    "imageData": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIoAAAAyCAYAAACDHkN8AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH5AYDDA8z7aYtxwAACOdJREFUeJztnG9sE/cZx79JuByJTVKKXajjkhSnEknAFgxthKglVdaQjgotlaq9AaSplVZ4NQl4OQ3EqxVV24uJPxLbC4I0oTCYMpgWV5Q0IwTU/JkNdgjxQZy4dpwzJJc4di7nP3vh2LNjOzn77pcSdB/JSnz3u9/z2P7e83ue584uiEajUSgorEDhj+2AwtpAEYqCKNaRNtDzVxvGBiZRsVMDQ4MOFTs2kTapQADiQhHmw5gYnsLE8BT6r4+gtrkS9UdrULa5lLRpBRkhvvQI86GU53azE+0nuvG0+wfSphVkZBWEEk7bNuMN4PbZh4pY1hDEhRLiQ1n33T77EI4eN2kXFGTgR4koydy7/BizkwHSbihIhLhQgtP8svunXH7cu2wj7YaCRIgLZdozt+KYJ3fH8ej2c9KuKEiAqFACUzyEYPYcJRlFKK82RIUy7fGLHusdmVbE8gpDVCice+VlJxlFKK8uZIUiIj9JxjsyDY/9JSFvFKRAVCgTT6ZyPsYzpAjlVYSsUIZz/9A99hcEPInhsrDoOP0ALgtLzMZawGZ24i9H/p3TMcQuCnKeOQS5hZyPExtReL8A9hmXtp1WUdAayjMeM27xgelxY3erIWe/1iosw4FWUykXYe2dTsx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4CtEJeYg2SjaUo+Sg7eIzK0gD6KT2WhwEiHHNQgj1xCZkre5U9JyHUUVH8o6p4K85F71RCMQHNcQGrmGsCf7XfBioXYcB/2zs5LnUSBL3n0UAAi7vkXY24vwROyRK1TtF6Dr/5CveYVVRJJQkokucAh7ehD29CDC9iEyO4ZoMPMtkYUbt4Oq/QLU9l/LYVphFZBNKAqvN8ovVyuIQhGKgigUoSiIQhGKgigUoSiIQhGKgij+B4V7vYMAPildAAAAAElFTkSuQmCC"
}

Please click on the links below to find instructions on how to insert an image file into your template using various services.

Rotate, flip, fit and stretch pictures

The picture formatter can be used with some additional options. Let’s check them all.

Note

You can easily combine different options within one token in order to achieve the desired result. For example, {{imageData}:picture(300, 300, Fit):rotate(90):flip(X)}

Rotate

This option rotates the source picture by 90, 180, or 270 degrees.

To use the option, add it to the picture formatter in your template.

{{imageData}:picture(100):rotate(90)}

Flip

This option flips the image horizontally and/or vertically.

Add it to the picture formatter in your template.

{{imageData}:picture(100):flip(X)}

{{imageData}:picture(100):flip(Y)}

{{imageData}:picture(100):flip(XY)}

Fit and Stretch

Resizing images is not yet supported for PPTX templates. However, it’s possible to keep the image proportions within the image placeholder by using the Fit option.

For example, if the image placeholder has these dimensions (250x370 px), add this token to the placeholder Alt text: {{imageData}:picture(250, 370, Fit)}

Stretch is the default behavior. The picture takes up the defined space and it may lose its original proportions.

Insert picture using various services

Let’s take a simple PPTX template prepared as described in the previous part of the article and insert a picture using Power Automate, Zapier, and Make.

This is the template:

Insert picture in PPTX

And the result:

Insert picture in PPTX

Download the PPTX template and the picture.

Power Automate

You can insert any image if you can get its Base64 code in Power Automate flow or even using some third-party services.

Let’s check out the next example.

Power Automate Flow

I download the PPTX template and the Image from a SharePoint folder.

Then I add the action Create document from PPTX template to my flow.

I use this code in the JSON to convert the uploaded image into base64 format:

base64(body('GetImage'))
Converting to base64

Zapier

In Zapier, you can insert an image into your template using a Download URL output from the previous action. Check out the following steps to achieve this.

1. Set up a trigger in Zapier that captures the image you want to insert into the template. I use OneDrive trigger but it could be any other trigger like Google Drive, Dropbox, etc.

Zapier insert image
  1. Set up the action Start Process in Plumsail Documents and use the Download URL output from the OneDrive trigger.

Zapier insert image

Make

To insert a picture into your template in Make convert it into a base64 string with the base64 function.

For example, let’s check this scenario.

  1. I download a source image from a OneDrive folder. Use any other connector to download the source images.

Make insert image
  1. Then I add the Plumsail Documents action and select a process to start.

Make insert image
  1. Next, add the base64 function.

Make insert image
  1. And finally select data from the OneDrive connector.

Make insert image