Page tree

Versions Compared

Key

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

...

Name

Description

Anchor
Top
Top
Top

Aligns the picture at the top of the slide.

Anchor
Middle
Middle
Middle

Aligns the picture in the middle of the slide.

Anchor
Bottom
Bottom
Bottom

Aligns the picture on the bottom of the slide.

Anchor
Left
Left
Left

Aligns the picture on the left side of the slide.

Anchor
Center
Center
Center

Aligns the picture in the center of the slide.

Anchor
Right
Right
Right

Aligns the picture on the right side of the slide.

Sample code

The code below demonstrates importing the image from an array and setting the alignment of the image.

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());

//Bind the image to the template
pptt.Process();

//Pass the template to PowerPointApplication
PowerPointApplication ppta = new PowerPointApplication();
Presentation pres = ppta.Open(pptt);

//Get the first slide in the presentation
Slide slide1 = pres.Slides[0];

//Get the first picture on the slide 
Pictures allPics = slide1.Pictures;
Picture pic = allPics[0];
            
//Set the alignment to be in the center of the slide, both horizontally and veritcally
pic.Align(Alignment.Center);
pic.Align(Alignment.Middle);

Code Block
titleInserting an Image from a byte array VB
languagevbnet
'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()

'Bind the data to the template
pptt.BindData(valuesArray, colNamesArray, "Company",pptt.CreateDataBindingProperties());
pptt.Process()

'Pass the template to PowerPointApplication
Dim ppta As PowerPointApplication = new PowerPointApplication()
Dim pres As Presentation = ppta.Open(pptt)

'Get the first slide in the presentation
Dim slide1 As Slide = pres.Slides(0)

//Get the first picture on the slide 
Dim allPics As Pictures = slide1.Pictures
Dim pic As Picture = allPics(0)
            
//Set the alignment to be in the center of the slide, both horizontally and veritcally
pic.Align(Alignment.Center)
pic.Align(Alignment.Middle)