PowerPointWriter allows you to insert images in data markers. Images can be inserted using the image modifier.
The image modifier can be used to insert images into a data marker. |
To insert an image into a data marker using the image modifier:
The image modifier can be used without dimensions either alone or with a scaling mode.
If the image modifier is used by itself, for example %%=Company.Logo(image), the image will maintain it's original dimensions.
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. |
The image modifier can take parameters specifying the image dimensions. Again, this can be done with or without the scaling mode.
The syntax for specifying an images dimensions without the scaling mode is image(width, height). For example %%=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 %%=Company.Logo(image(3,1,2)) would use the third scaling value.
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. |
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.
//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(); |
'The ReadAllBytes method can be used to create a byte array from an image filepath. Dim imgArray as Byte() = File.ReadAllBytes(@"C:\image.png") 'create an object array of values to be populated Dim valuesArray as Object() = new Object() {imgArray} 'create a string array of column names. 'the field names must match the data marker column names in the template. Dim colNames = New String() {"Logo(image(1,2,2))"} Dim DataProps As DataBindingProperties = pptt.CreateDataBindingProperties() pptt.BindData(valuesArray, colNamesArray, "Company",pptt.CreateDataBindingProperties()); |