Interface IShapes
Represents a collection of IShape instance in a slide.
Namespace: Syncfusion.Presentation
Assembly: Syncfusion.Presentation.UWP.dll
Syntax
public interface IShapes : IEnumerable<ISlideItem>, IEnumerable
Properties
Count
Gets the number of elements in the shape collection. Read-only.
Declaration
int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The count. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Add auto shape - rectangle to slide
IShape shape = shapes.AddShape(AutoShapeType.Rectangle,300,200,150,200);
//Add chart to slide
IPresentationChart chart =shapes.AddChart(500, 300, 100, 100);
//Set the chart title
chart.ChartTitle = "Chart";
//Get the count for shape collection
int count = shapes.Count;
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Add auto shape - rectangle to slide
Dim shape As IShape = shapes.AddShape(AutoShapeType.Rectangle, 300, 200, 150, 200)
'Add chart to slide
Dim chart As IPresentationChart = shapes.AddChart(500, 300, 100, 100)
'Set the chart title
chart.ChartTitle = "Chart"
'Get the count for shape collection
Dim count As Integer = shapes.Count
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Item[Int32]
Gets a ISlideItem instance at the specified index from the shape collection. Read-only.
Declaration
ISlideItem this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Specifies the slide item index to locate. |
Property Value
Type | Description |
---|---|
ISlideItem | Returns an ISlideItem instance. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleAndContent);
//Get the shape collection of slide
IShapes shapes = slide.Shapes;
//Create instance for SlideItem
ISlideItem slideItem = shapes[0];
//Set the description for slide item
slideItem.Description = "This is a SlideItem";
//Set the title
slideItem.Title = "SlideItem";
//Add the slide item
shapes.Add(slideItem);
//Save the presentation
presentation.Save("Cells.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.TitleAndContent)
'Get the shape collection of slide
Dim shapes As IShapes = slide.Shapes
'Create instance for SlideItem
Dim slideItem As ISlideItem = shapes(0)
'Set the description for slide item
slideItem.Description = "This is a SlideItem"
'Set the title
slideItem.Title = "SlideItem"
'Add the slide item
shapes.Add(slideItem)
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()
Methods
Add(ISlideItem)
Adds the specified ISlideItem instance at the end of the shape collection.
Declaration
int Add(ISlideItem shape)
Parameters
Type | Name | Description |
---|---|---|
ISlideItem | shape | The ISlideItem instance to be added. |
Returns
Type | Description |
---|---|
System.Int32 | Returns the zero-based index of the newly added shape within the shape collection. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleAndContent);
//Get the shape collection of slide
IShapes shapes = slide.Shapes;
//Create instance for SlideItem
ISlideItem slideItem = shapes[0];
//Set the description for slide item
slideItem.Description = "This is a SlideItem";
//Set the title
slideItem.Title = "SlideItem";
//Add the slide item
shapes.Add(slideItem);
//Save the presentation
presentation.Save("Cells.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.TitleAndContent)
'Get the shape collection of slide
Dim shapes As IShapes = slide.Shapes
'Create instance for SlideItem
Dim slideItem As ISlideItem = shapes(0)
'Set the description for slide item
slideItem.Description = "This is a SlideItem"
'Set the title
slideItem.Title = "SlideItem"
'Add the slide item
shapes.Add(slideItem)
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()
AddChart(IEnumerable, Double, Double, Double, Double)
Creates a chart from the specified enumerable and adds the chart to the shape collection.
Declaration
IPresentationChart AddChart(IEnumerable enumerable, double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | enumerable | Specifies the System.Collections.IEnumerable object with desired data |
System.Double | left | Represents the left position, in points. The Left value ranges from -169056 to 169056. |
System.Double | top | Represents the top position, in points. The Top value ranges from -169056 to 169056. |
System.Double | width | Represents the width, in points. The Width value ranges from 0 to 169056. |
System.Double | height | Represents the height, in points. The Height value ranges from 0 to 169056. |
Returns
Type | Description |
---|---|
IPresentationChart | Returns an IPresentationChart instance this method creates. |
AddChart(Double, Double, Double, Double)
Adds a new chart to the shape collection.
Declaration
IPresentationChart AddChart(double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Double | left | Represents the left position, in points. The Left value ranges from -169056 to 169056. |
System.Double | top | Represents the top position, in points. The Top value ranges from -169056 to 169056. |
System.Double | width | Represents the width, in points. The Width value ranges from 0 to 169056. |
System.Double | height | Represents the height, in points. The Height value ranges from 0 to 169056. |
Returns
Type | Description |
---|---|
IPresentationChart | Returns an IPresentationChart instance this method creates. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Add chart to slide
IPresentationChart chart =shapes.AddChart(400, 300, 100, 100);
//Set the fore color of the chart area.
chart.ChartArea.Fill.ForeColor = Color.AliceBlue;
//Set the chart title
chart.ChartTitle = "Chart";
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Add chart to slide
Dim chart As IPresentationChart = shapes.AddChart(400, 300, 100, 100)
'Set the fore color of the chart area.
chart.ChartArea.Fill.ForeColor = Color.AliceBlue
'Set the chart title
chart.ChartTitle = "Chart"
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
AddChart(Stream, Int32, String, RectangleF)
Creates a chart for the data in specified excel document and adds the chart to the shape collection.
Declaration
IPresentationChart AddChart(Stream excelStream, int sheetNumber, string dataRange, RectangleF bounds)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | excelStream | Excel document stream having the data for chart[Only the "*.xlsx" format is supported]. |
System.Int32 | sheetNumber | Worksheet number of the excel document. |
System.String | dataRange | Data range in the worksheet for the chart to be created. |
RectangleF | bounds | Position and size of the chart, in points. |
Returns
Type | Description |
---|---|
IPresentationChart | Returns an IPresentationChart instance this method creates. |
Examples
//Creates a Presentation instance
IPresentation pptxDoc = Presentation.Create();
//Adds a blank slide to the Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Gets the excel file as stream
FileStream excelStream = new FileStream("Book1.xlsx", FileMode.Open);
//Adds a chart to the slide with a data range from excel worksheet – excel workbook, worksheet number, Data range, position, and size.
IPresentationChart chart = slide.Charts.AddChart(excelStream, 1, "A1:D4", new RectangleF(100, 10, 700, 500));
//Save the presentation
pptxDoc.Save("Output.pptx");
//Closes the Presentation
pptxDoc.Close();
'Creates a Presentation instance
Dim pptxDoc As IPresentation = Presentation.Create()
'Adds a blank slide to the Presentation
Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
'Gets the excel file as stream
Dim excelStream As New MemoryStream(File.ReadAllBytes("Book1.xlsx"))
'Adds a chart to the slide with a data range from excel worksheet – excel workbook, worksheet number, Data range, position, and size.
Dim chart As IPresentationChart = slide.Charts.AddChart(excelStream, 1, "A1:D4", New RectangleF(100, 10, 700, 500))
'Saves the Presentation
pptxDoc.Save("output.pptx")
'Closes the Presentation
pptxDoc.Close()
AddChart(Object[][], Double, Double, Double, Double)
Declaration
IPresentationChart AddChart(object[][] data, double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Object[][] | data | |
System.Double | left | |
System.Double | top | |
System.Double | width | |
System.Double | height |
Returns
Type |
---|
IPresentationChart |
AddChart(StorageFile, Int32, String, RectangleF)
Creates a chart for the data in specified excel document and adds the chart to the shape collection.
Declaration
IPresentationChart AddChart(StorageFile excelFile, int sheetNumber, string dataRange, RectangleF bounds)
Parameters
Type | Name | Description |
---|---|---|
Windows.Storage.StorageFile | excelFile | The Excel document Windows.Storage.StorageFile having the data for chart[Only the "*.xlsx" format is supported] |
System.Int32 | sheetNumber | Worksheet number of the excel document. |
System.String | dataRange | Data range in the worksheet for the chart to be created. |
RectangleF | bounds | Position and size of the chart, in points. |
Returns
Type | Description |
---|---|
IPresentationChart | Returns an IPresentationChart instance. |
AddConnector(ConnectorType, IShape, Int32, IShape, Int32)
Adds a IConnector to the shape collection of a Slide.
Declaration
IConnector AddConnector(ConnectorType connectorType, IShape beginShape, int beginSiteIndex, IShape endShape, int endSiteIndex)
Parameters
Type | Name | Description |
---|---|---|
ConnectorType | connectorType | Determines the connector type |
IShape | beginShape | |
System.Int32 | beginSiteIndex | |
IShape | endShape | |
System.Int32 | endSiteIndex |
Returns
Type | Description |
---|---|
IConnector | Returns an IConnector instance this method creates. |
Examples
// Create a new presentation.
IPresentation ppDoc = Presentation.Create();
// Add a slide to the presentation.
ISlide slide = ppDoc.Slides.Add(SlideLayoutType.Blank);
// Add a Rectangle shape on the slide
IShape rectangle = slide.Shapes.AddShape(AutoShapeType.Rectangle, 200, 200, 250, 250);
// Add a Oval shape on the slide
IShape oval = slide.Shapes.AddShape(AutoShapeType.Rectangle, 600, 100, 250, 250);
// Add connector on the slide and connect the end points of connector
IConnector connector = slide.Shapes.AddConnector(ConnectorType.Straight, rectangle, 0, oval, 3);
// Save the presentation file
ppDoc.Save("Sample.pptx");
// Close the presentation file
ppDoc.Close();
' Create a new presentation.
Dim ppDoc As IPresentation = Presentation.Create()
' Add a slide to the presentation.
Dim slide As ISlide = ppDoc.Slides.Add(SlideLayoutType.Blank)
' Add Rectangle shape on the slide
Dim rectangle As IShape = slide.Shapes.AddShape(AutoShapeType.Rectangle, 200, 200, 250, 250)
' Add Oval shae on the slide
Dim oval As IShape = slide.Shapes.AddShape(AutoShapeType.Rectangle, 600, 100, 250, 250)
' Add connector on the slide and connect the end points of connector
Dim connector As IConnector = slide.Shapes.AddConnector(ConnectorType.Straight, rectangle, 0, oval, 3)
' Save the presentation file
ppDoc.Save("Sample.pptx")
' Close the presentation file
ppDoc.Close
AddConnector(ConnectorType, Double, Double, Double, Double)
Adds a IConnector to the shape collection of a Slide.
Declaration
IConnector AddConnector(ConnectorType connectorType, double beginX, double beginY, double endX, double endY)
Parameters
Type | Name | Description |
---|---|---|
ConnectorType | connectorType | Determines the connector type |
System.Double | beginX | Represents the begin X of connector. The begin X value ranges from -169055 to 169056. |
System.Double | beginY | Represents the begin Y of connector. The begin Y value ranges from -169055 to 169056. |
System.Double | endX | Represents the end X of connector. The end X value ranges from -169055 to 169056. |
System.Double | endY | Represents the end Y of connector. The end Y value ranges from -169055 to 169056. |
Returns
Type | Description |
---|---|
IConnector | Returns an IConnector instance this method creates. |
Examples
// Create a new presentation.
IPresentation ppDoc = Presentation.Create();
// Add a slide to the presentation.
ISlide slide = ppDoc.Slides.Add(SlideLayoutType.Blank);
// Add connector on the slide
IConnector connector = slide.Shapes.AddConnector(ConnectorType.Straight, 150, 150, 300, 300);
// Save the presentation file
ppDoc.Save("Sample.pptx");
// Close the presentation file
ppDoc.Close();
' Create a new presentation.
Dim ppDoc As IPresentation = Presentation.Create()
' Add a slide to the presentation.
Dim slide As ISlide = ppDoc.Slides.Add(SlideLayoutType.Blank)
' Add connector on the slide
Dim connector As IConnector = slide.Shapes.AddConnector(ConnectorType.Straight, 150, 150, 300, 300)
' Save the presentation file
ppDoc.Save("Sample.pptx")
' Close the presentation file
ppDoc.Close
AddGroupShape(Double, Double, Double, Double)
Creates a group shape and adds the group shape to the shape collection.
Declaration
IGroupShape AddGroupShape(double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Double | left | Represents the left position, in points. The Left value ranges from -169056 to 169056. |
System.Double | top | Represents the top position, in points. The Top value ranges from -169056 to 169056. |
System.Double | width | Represents the width, in points. The Width value ranges from 0 to 169056. |
System.Double | height | Represents the height, in points. The Height value ranges from 0 to 169056. |
Returns
Type | Description |
---|---|
IGroupShape | Returns an IGroupShape instance this method creates. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Add a group shape to the slide
IGroupShape groupShape = shapes.AddGroupShape(12, 12, 200, 200);
//Add auto shapes to group shape
groupShape.Shapes.AddShape(AutoShapeType.Oval, 47, 50, 60, 120);
groupShape.Shapes.AddShape(AutoShapeType.Rectangle, 12, 12, 40, 30);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Add a group shape to the slide
Dim groupShape As IGroupShape = shapes.AddGroupShape(12, 12, 200, 200)
'Add auto shapes to group shape
groupShape.Shapes.AddShape(AutoShapeType.Oval, 47, 50, 60, 120)
groupShape.Shapes.AddShape(AutoShapeType.Rectangle, 12, 12, 40, 30)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
AddOleObject(Stream, String, Stream)
Creates an IOleObject instance with the specified image, program id, and data, then adds it to the IShapes collection.
Declaration
IOleObject AddOleObject(Stream image, string progId, Stream oleData)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | image | Image used to be displayed |
System.String | progId | The ProgID of the object to be embedded |
System.IO.Stream | oleData | File stream from which the object is to be created |
Returns
Type |
---|
IOleObject |
Examples
//Create new instance of PowerPoint presentation.
IPresentation pptxDoc = Presentation.Create();
//Add slide with blank layout to presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Get the excel file as stream
Stream excelStream = File.Open("OleTemplate.xlsx", FileMode.Open);
//Image to be displayed, This can be any image
Stream imageStream = File.Open("OlePicture.png", FileMode.Open);
//Add an OLE object to the slide
IOleObject oleObject = slide.Shapes.AddOleObject(imageStream, "Excel.Sheet.12", excelStream);
//Set size and position of the OLE object
oleObject.Left = 10;
oleObject.Top = 10;
oleObject.Width = 400;
oleObject.Height = 300;
//Save the presentation
pptxDoc.Save("Sample.pptx");
//Close the presentation
pptxDoc.Close();
'Create new instance of PowerPoint presentation.
Dim pptxDoc As IPresentation = Presentation.Create()
'Add slide with blank layout to presentation
Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
'Get the excel file as stream
Dim excelStream As Stream = File.Open("OleTemplate.xlsx", FileMode.Open)
'Image to be displayed, This can be any image
Dim imageStream As Stream = File.Open("OlePicture.png", FileMode.Open)
'Add an OLE object to the slide
Dim oleObject As IOleObject = slide.Shapes.AddOleObject(imageStream, "Excel.Sheet.12", excelStream)
'Set size and position of the OLE object
oleObject.Left = 10
oleObject.Top = 10
oleObject.Width = 400
oleObject.Height = 300
'Save the presentation
pptxDoc.Save("Sample.pptx")
'Close the presentation
pptxDoc.Close()
AddOleObject(Stream, String, String)
Creates an IOleObject instance with the specified image, program id, and data, then adds it to the IShapes collection.
Declaration
IOleObject AddOleObject(Stream image, string progId, string pathLink)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | image | Image used to be displayed |
System.String | progId | The ProgID of the object to be embedded |
System.String | pathLink | String path from which the object is to be created |
Returns
Type |
---|
IOleObject |
Examples
//Create new instance of PowerPoint presentation.
IPresentation pptxDoc = Presentation.Create();
//Add slide with blank layout to presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Image to be displayed, This can be any image
Stream imageStream = File.Open("OlePicture.png", FileMode.Open);
//Add an OLE object to the slide
IOleObject oleObject = slide.Shapes.AddOleObject(imageStream, "Excel.Sheet.12", "OleTemplate.xlsx");
//Set size and position of the OLE object
oleObject.Left = 10;
oleObject.Top = 10;
oleObject.Width = 400;
oleObject.Height = 300;
//Save the presentation
pptxDoc.Save("Sample.pptx");
//Close the presentation
pptxDoc.Close();
'Create new instance of PowerPoint presentation.
Dim pptxDoc As IPresentation = Presentation.Create()
'Add slide with blank layout to presentation
Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
'Image to be displayed, This can be any image
Dim imageStream As Stream = File.Open("OlePicture.png", FileMode.Open)
'Add an OLE object to the slide
Dim oleObject As IOleObject = slide.Shapes.AddOleObject(imageStream, "Excel.Sheet.12", "OleTemplate.xlsx")
'Set size and position of the OLE object
oleObject.Left = 10
oleObject.Top = 10
oleObject.Width = 400
oleObject.Height = 300
'Save the presentation
pptxDoc.Save("Sample.pptx")
'Close the presentation
pptxDoc.Close()
AddPicture(Stream, Double, Double, Double, Double)
Declaration
IPicture AddPicture(Stream pictureStream, double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | pictureStream | |
System.Double | left | Represents the left position, in points. The Left value ranges from -169056 to 169056. |
System.Double | top | Represents the top position, in points. The Top value ranges from -169056 to 169056. |
System.Double | width | Represents the width, in points. The Width value ranges from 0 to 169056. |
System.Double | height | Represents the height, in points. The Height value ranges from 0 to 169056. |
Returns
Type | Description |
---|---|
IPicture | Returns an IPicture instance this method creates. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Get the image from file path
Image image = Image.FromFile("Image.gif");
// Add the image to the slide by specifying position and size
shapes.AddPicture(new MemoryStream(image.ImageData), 300, 120, 70, 40);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Get the image from file path
Dim image__2 As Image = Image.FromFile("Image.gif")
' Add the image to the slide by specifying position and size
shapes.AddPicture(New MemoryStream(image__2.ImageData), 300, 120, 70, 40)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
AddPicture(Stream, Stream, Double, Double, Double, Double)
Creates a picture from the specified svg, its fallback image stream and adds the picture to the shape collection.
Declaration
IPicture AddPicture(Stream svgStream, Stream imageStream, double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | svgStream | The System.IO.Stream instance of SVG image. |
System.IO.Stream | imageStream | The System.IO.Stream instance of fallback image. |
System.Double | left | Represents the left position, in points. The Left value ranges from -169056 to 169056. |
System.Double | top | Represents the top position, in points. The Top value ranges from -169056 to 169056. |
System.Double | width | Represents the width, in points. The Width value ranges from 0 to 169056. |
System.Double | height | Represents the height, in points. The Height value ranges from 0 to 169056. |
Returns
Type | Description |
---|---|
IPicture | Returns an IPicture instance. |
Examples
//Create a new presentation.
IPresentation presDoc = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presDoc.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Create an instance for fallback image as stream
Stream imageStream = File.Open("Image.gif", FileMode.Open);
//Create an instance for vector image as stream
Stream svgStream = File.Open("Image.svg", FileMode.Open);
// Add the image to the slide by specifying position and size
shapes.AddPicture(svgStream, imageStream, 300, 120, 70, 40);
//Save the presentation
presDoc.Save("Sample.pptx");
//Close the presentation
presDoc.Close();
'Create a new presentation.
Dim presDoc As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presDoc.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Create an instance for fallback image as stream
Dim imageStream As Stream = File.Open("Image.gif", FileMode.Open)
'Create an instance for vector image as stream
Dim svgStream As Stream = File.Open("Image.svg", FileMode.Open)
'Add the image to the slide by specifying position and size
shapes.AddPicture(svgStream, imageStream, 300, 120, 70, 40)
'Save the presentation
presDoc.Save("Sample.pptx")
'Close the presentation
presDoc.Close()
AddShape(AutoShapeType, Double, Double, Double, Double)
Creates a shape for the specified AutoShapeType and adds the shape to the shape collection.
Declaration
IShape AddShape(AutoShapeType type, double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
AutoShapeType | type | Determines the auto shape type. |
System.Double | left | Represents the left position, in points. The Left value ranges from -169056 to 169056. |
System.Double | top | Represents the top position, in points. The Top value ranges from -169056 to 169056. |
System.Double | width | Represents the width, in points. The Width value ranges from 0 to 169056. |
System.Double | height | Represents the height, in points. The Height value ranges from 0 to 169056. |
Returns
Type | Description |
---|---|
IShape | Returns an IShape instance this method creates. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Add auto shape - rectangle to slide
IShape shape = shapes.AddShape(AutoShapeType.Rectangle,300,200,150,200);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Add auto shape - rectangle to slide
Dim shape As IShape = shapes.AddShape(AutoShapeType.Rectangle, 300, 200, 150, 200)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
AddSmartArt(SmartArtType, Double, Double, Double, Double)
Adds a ISmartArt to the shape collection of a Slide.
Declaration
ISmartArt AddSmartArt(SmartArtType smartArtType, double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
SmartArtType | smartArtType | The SmartArt type to add. |
System.Double | left | Represents the left position, in points. The left value ranges from -169056 to 169056. |
System.Double | top | Represents the top position, in points. The top value ranges from -169056 to 169056. |
System.Double | width | Represents the width, in points. The width value ranges from 0 to 169056. |
System.Double | height | Represents the height, in points. The height value ranges from 0 to 169056. |
Returns
Type | Description |
---|---|
ISmartArt | Returns an ISmartArt instance that represents the new SmartArt diagram. |
Examples
// Create an instance of PowerPoint Presentation
IPresentation pptxDoc = Presentation.Create();
//Add a blank slide to the Presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Add a BasicBlockList SmartArt to the slide at the specified size and position.
ISmartArt smartArt = slide.Shapes.AddSmartArt(SmartArtType.BasicBlockList, 100, 50, 640, 426);
//Save the PowerPoint Presentation.
pptxDoc.Save("Sample.pptx");
//Close the Presentation
pptxDoc.Close();
'Create an instance of PowerPoint Presentation
Dim pptxDoc As IPresentation = Presentation.Create()
'Add a blank slide to the Presentation
Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
'Add a BasicBlockList SmartArt to the slide at the specified size and position.
Dim smartArt As ISmartArt = slide.Shapes.AddSmartArt(SmartArtType.BasicBlockList, 100, 50, 640, 426)
'Save the Presentation
pptxDoc.Save("Sample.pptx")
'Close the Presentation
pptxDoc.Close()
AddTable(Int32, Int32, Double, Double, Double, Double)
Adds a new table to the shape collection with the specified number of rows and columns. The valid range is 1 to 75.
Declaration
ITable AddTable(int rowCount, int columnCount, double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowCount | Represents the number of rows. The valid range is 1 to 75. |
System.Int32 | columnCount | Represents the number of columns. The valid range is 1 to 75 |
System.Double | left | Represents the left position, in points. The Left value ranges from -169056 to 169056. |
System.Double | top | Represents the top position, in points. The Top value ranges from -169056 to 169056. |
System.Double | width | Represents the width, in points. The Width value ranges from 0 to 169056. |
System.Double | height | Represents the height, in points. The Height value ranges from 0 to 169056. |
Returns
Type | Description |
---|---|
ITable | Returns an ITable instance this method creates. |
Examples
//Create a new presentation
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Add table to the shape collection
ITable table = shapes.AddTable(2, 2, 100, 120, 300, 200);
//Retrieve each cell and fill text content to the cell.
ICell cell = table[0, 0];
cell.TextBody.AddParagraph("First Row and First Column");
cell = table[0, 1];
cell.TextBody.AddParagraph("First Row and Second Column");
cell = table[1, 0];
cell.TextBody.AddParagraph("Second Row and First Column");
cell = table[1, 1];
cell.TextBody.AddParagraph("Second Row and Second Column");
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Add table to the shape collection
Dim table As ITable = shapes.AddTable(2, 2, 100, 120, 300, 200)
'Retrieve each cell and fill text content to the cell.
Dim cell As ICell = table(0, 0)
cell.TextBody.AddParagraph("First Row and First Column")
cell = table(0, 1)
cell.TextBody.AddParagraph("First Row and Second Column")
cell = table(1, 0)
cell.TextBody.AddParagraph("Second Row and First Column")
cell = table(1, 1)
cell.TextBody.AddParagraph("Second Row and Second Column")
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
AddTextBox(Double, Double, Double, Double)
Adds a new text box to the shape collection.
Declaration
IShape AddTextBox(double left, double top, double width, double height)
Parameters
Type | Name | Description |
---|---|---|
System.Double | left | Represents the left position, in points. The Left value ranges from -169056 to 169056. |
System.Double | top | Represents the top position, in points. The Top value ranges from -169056 to 169056. |
System.Double | width | Represents the width, in points. The Width value ranges from 0 to 169056. |
System.Double | height | Represents the height, in points. The Height value ranges from 0 to 169056. |
Returns
Type | Description |
---|---|
IShape | Returns an IShape instance this method creates. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Add text box to slide
IShape textBox = shapes.AddTextBox(100, 30, 100, 200);
//Add a paragraph with text content.
IParagraph paragraph = textBox.TextBody.AddParagraph("This is a Text Box");
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Add text box to slide
Dim textBox As IShape = shapes.AddTextBox(100, 30, 100, 200)
'Add a paragraph with text content.
Dim paragraph As IParagraph = textBox.TextBody.AddParagraph("This is a Text Box")
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Clear()
Removes all the elements from shape collection.
Declaration
void Clear()
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Add text box to slide
IShape textBox = shapes.AddTextBox(100, 30, 100, 200);
//Add a paragraph with text content.
IParagraph paragraph = textBox.TextBody.AddParagraph("This is a Text Box");
//Clear the shapes
shapes.Clear();
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Add text box to slide
Dim textBox As IShape = shapes.AddTextBox(100, 30, 100, 200)
'Add a paragraph with text content.
Dim paragraph As IParagraph = textBox.TextBody.AddParagraph("This is a Text Box")
'Clear the shapes
shapes.Clear()
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
IndexOf(ISlideItem)
Returns the zero-based index of the first occurrence of the specified ISlideItem within the shape collection.
Declaration
int IndexOf(ISlideItem value)
Parameters
Type | Name | Description |
---|---|---|
ISlideItem | value | The ISlideItem instance to locate. |
Returns
Type | Description |
---|---|
System.Int32 | Returns the zero-based index of the first occurrence of specified slide item within the shape collection, if found; otherwise, –1. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Add text box to slide
IShape textBox = shapes.AddTextBox(100, 30, 100, 200);
//Add a paragraph with text content.
IParagraph paragraph = textBox.TextBody.AddParagraph("This is a Text Box");
//Get the index of specific shape
int index = shapes.IndexOf(textBox);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Add text box to slide
Dim textBox As IShape = shapes.AddTextBox(100, 30, 100, 200)
'Add a paragraph with text content.
Dim paragraph As IParagraph = textBox.TextBody.AddParagraph("This is a Text Box")
'Get the index of specific shape
Dim index As Integer = shapes.IndexOf(textBox)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Insert(Int32, ISlideItem)
Inserts an element into the shape collection at the specified index.
Declaration
void Insert(int index, ISlideItem value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index at which item should be inserted. |
ISlideItem | value | The slide item to insert in the collection. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Add text box to slide
IShape textBox = shapes.AddTextBox(100, 30, 100, 200);
//Add a paragraph with text content.
IParagraph paragraph = textBox.TextBody.AddParagraph("This is a Text Box");
//Insert shape at specific index
shapes.Insert(1, textBox);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Add text box to slide
Dim textBox As IShape = shapes.AddTextBox(100, 30, 100, 200)
'Add a paragraph with text content.
Dim paragraph As IParagraph = textBox.TextBody.AddParagraph("This is a Text Box")
'Insert shape at specific index
shapes.Insert(1, textBox)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
Remove(ISlideItem)
Removes the first occurrence of a specified slide from the shape collection.
Declaration
void Remove(ISlideItem item)
Parameters
Type | Name | Description |
---|---|---|
ISlideItem | item | The shape to be removed from the collection. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Add text box to slide
IShape textBox = shapes.AddTextBox(100, 30, 100, 200);
//Add a paragraph with text content.
IParagraph paragraph = textBox.TextBody.AddParagraph("This is a Text Box");
//Remove specific shape from collection
shapes.Remove(textBox);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Add text box to slide
Dim textBox As IShape = shapes.AddTextBox(100, 30, 100, 200)
'Add a paragraph with text content.
Dim paragraph As IParagraph = textBox.TextBody.AddParagraph("This is a Text Box")
'Remove specific shape from collection
shapes.Remove(textBox)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
RemoveAt(Int32)
Removes the element at the specified index of the shape collection.
Declaration
void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the shape to be removed. |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Create instance for shapes collection
IShapes shapes = slide.Shapes;
//Add text box to slide
IShape textBox = shapes.AddTextBox(100, 30, 100, 200);
//Add a paragraph with text content.
IParagraph paragraph = textBox.TextBody.AddParagraph("This is a Text Box");
//Remove shape at specific index
shapes.RemoveAt(0);
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Create instance for shapes collection
Dim shapes As IShapes = slide.Shapes
'Add text box to slide
Dim textBox As IShape = shapes.AddTextBox(100, 30, 100, 200)
'Add a paragraph with text content.
Dim paragraph As IParagraph = textBox.TextBody.AddParagraph("This is a Text Box")
'Remove shape at specific index
shapes.RemoveAt(0)
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()