Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create or open a PowerPointTemplate
  2. Add the image modifier in parenthese to the data marker in which you want to insert the image. For example, change %%=Company.Logo to %%=Company.Logo(image)
  3. If desired, set the 'image' modifier's sizing mode

...

Setting the Image

...

size

There are three ways the image size can be determined.
1. The image is already the desired size
If the image modifier is used by itself, for example %%=Company.Logo(image), without arguments the image will maintain it's original dimensions.
ex. %%=Company.Logo(image)

2. The image should take on the size of the textbox containing the data marker.
If the image modifier is used with a scaling mode, %%=Company.Logo(image(1)), the image will be scaled accordingly and sized to fit the containing text box.
The scaling mode can have the following values:

Value

Meaning

1

The image will always be the width and height specified regardless of its natural size.

2

The image will always be enlarged or shrunk to fit within the bounds specified by width and height but it will keep its natural aspect ratio.

3

The image will be scaled down to within the bounds specified by width and height but it will keep its natural aspect ratio.

Using the Image modifier with dimensions

ex:%%=Company.Logo(image(1))

3. The image dimensions are given as arguments in the image modifier.
The image modifier can take parameters specifying the image dimensions. Again, this Dimensions can be done used with or without the a scaling mode. All dimensions are in inches.
The syntax for specifying an images dimensions without the scaling mode is image(width, height). For example
ex. %%=Company.Logo(1,2). All dimensions are in inches.
To use a scaling mode, add it as the first parameter in your modifier. For example, the data marker
ex. %%=Company.Logo(image(3,1,2)) would use the third scaling value.

Anchor
modes
modes

The scaling mode can have the following values:

Value

Meaning

1

The image will always be the width and height specified regardless of its natural size.

2

The image will always be enlarged or shrunk to fit within the bounds specified by width and height but it will keep its natural aspect ratio.

3

The image will be scaled down to within the bounds specified by width and height but it will keep its natural aspect ratio.

Images from databases

Writing the Code

Image datatypes

If you are using a database as a data source, the column that corresponds to the data marker containing the image must be of the type BLOB("Image" in SQL Server).
If the data source is an array of objects, the value that corresponds to the data marker containing the image should be a simple byte array.

Aligning the Image

Note: This feature requires PowerPointApplication

Sample code

Code Block
titleInserting an Image from a byte array C#
languagecsharp
//The ReadAllBytes method can be used to create a byte array from an image filepath.
byte[] imgArray = File.ReadAllBytes(@"C:\image.png");

//create an object array of values to be populated
object[] valuesArray = {imgArray};

//create a string array of column names.
//the field names must match the data marker column names in the template.
string[] colNamesArray = {"Logo(image(1,2,2))"};

//set the data source
pptt.BindData(valuesArray, colNamesArray, "Company",pptt.CreateDataBindingProperties());

pptt.Process();

...