Interface IBaseSlide
Represents a base slide in a presentation.
Namespace: Syncfusion.Presentation
Assembly: Syncfusion.Presentation.UWP.dll
Syntax
public interface IBaseSlide
Remarks
Contains members which are common for slide, layout slide and master slide.
Properties
Background
Gets the background of a slide. Read-only.
Declaration
IBackground Background { get; }
Property Value
Type |
---|
IBackground |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a slide to the presentation.
ISlide slide = presentation.Slides.Add();
//Retrieve the background.
IBackground background = slide.Background;
//Retrieve the fill of the background.
IFill fill = background.Fill;
//Set the fill type as gradient.
fill.FillType = FillType.Gradient;
//Retrieve the gradient fill.
IGradientFill gradientFill = fill.GradientFill;
//Add the first gradient stop.
gradientFill.GradientStops.Add();
//Add the second gradient stop.
gradientFill.GradientStops.Add();
//Save the presentation.
presentation.Save("Output.pptx");
//Close the presentation.
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a slide to the presentation.
Dim slide As ISlide = presentation__1.Slides.Add()
'Retrieve the background.
Dim background As IBackground = slide.Background
'Retrieve the fill of the background.
Dim fill As IFill = background.Fill
'Set the fill type as gradient.
fill.FillType = FillType.Gradient
'Retrieve the gradient fill.
Dim gradientFill As IGradientFill = fill.GradientFill
'Add the first gradient stop.
gradientFill.GradientStops.Add()
'Add the second gradient stop.
gradientFill.GradientStops.Add()
'Save the presentation.
presentation__1.Save("Output.pptx")
'Close the presentation.
presentation__1.Close()
Charts
Gets an IPresentationCharts collection that represents the charts in a slide. Read-only.
Declaration
IPresentationCharts Charts { get; }
Property Value
Type |
---|
IPresentationCharts |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Get the chart collection from slide
IPresentationCharts charts = slide.Charts;
//Add chart to slide
IPresentationChart chart =charts.AddChart(400, 300, 100, 100);
//Set the chart title
chart.ChartTitle = "Chart";
//Save the presentation
presentation.Save("Output.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)
'Get the chart collection from slide
Dim charts As IPresentationCharts = slide.Charts
'Add chart to slide
Dim chart As IPresentationChart = charts.AddChart(400, 300, 100, 100)
'Set the chart title
chart.ChartTitle = "Chart"
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()
GroupShapes
Gets an IGroupShapes instance that represents the GroupShape collection in a slide. Read-only.
Declaration
IGroupShapes GroupShapes { get; }
Property Value
Type |
---|
IGroupShapes |
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 group shapes, it is read only
IGroupShapes groupShapes = slide.GroupShapes;
//Add group shape to the collection
IGroupShape groupShape1 = groupShapes.AddGroupShape(12, 12, 300, 350);
IGroupShape groupShape2 = groupShapes.AddGroupShape(34, 50, 200, 100);
IGroupShape groupShape3 = groupShapes.AddGroupShape(70, 30, 120, 100);
//Save the presentation
presentation.Save("GroupShapes.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 group shapes, it is read only
Dim groupShapes As IGroupShapes = slide.GroupShapes
'Add group shape to the collection
Dim groupShape1 As IGroupShape = groupShapes.AddGroupShape(12, 12, 300, 350)
Dim groupShape2 As IGroupShape = groupShapes.AddGroupShape(34, 50, 200, 100)
Dim groupShape3 As IGroupShape = groupShapes.AddGroupShape(70, 30, 120, 100)
'Save the presentation
presentation__1.Save("GroupShapes.pptx")
'Close the presentation
presentation__1.Close()
HeadersFooters
Gets a HeadersFooters for the specified slide.
Declaration
IHeadersFooters HeadersFooters { get; }
Property Value
Type |
---|
IHeadersFooters |
Remarks
Returns an IHeadersFooters object that represents the HeaderFooter collection of a slide.
Name
Gets or sets the name of a slide.
Declaration
string Name { get; set; }
Property Value
Type |
---|
System.String |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Set the name of the slide
slide.Name = "My Slide";
//Save the presentation
presentation.Save("Slide.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)
'Set the name of the slide
slide.Name = "My Slide"
'Save the presentation
presentation__1.Save("Slide.pptx")
'Close the presentation
presentation__1.Close()
Pictures
Gets an IPictures instance that represents the collection of all pictures in a slide. Read-only.
Declaration
IPictures Pictures { get; }
Property Value
Type |
---|
IPictures |
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("Picture.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)
'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("Picture.pptx")
'Close the presentation
presentation__1.Close()
Shapes
Gets a IShapes collection that represents all the elements in the slide. Read-only.
Declaration
IShapes Shapes { get; }
Property Value
Type |
---|
IShapes |
Remarks
The IShapes collection can contain the drawings, shapes, pictures, text objects, titles, headers, footers, slide numbers, and date and time objects on a slide.
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,400,150,200);
//Save the presentation
presentation.Save("Shapes.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, 400, 150, 200)
'Save the presentation
presentation__1.Save("Shapes.pptx")
'Close the presentation
presentation__1.Close()
SlideSize
Gets the slide size for the presentation. Read-only.
Declaration
ISlideSize SlideSize { get; }
Property Value
Type |
---|
ISlideSize |
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Retrieve the side size
ISlideSize slideSize = slide.SlideSize;
//Set slide orientation
slideSize.SlideOrientation = SlideOrientation.Landscape;
//Save the presentation
presentation.Save("Output.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)
'Retrieve the side size
Dim slideSize As ISlideSize = slide.SlideSize
'Set slide orientation
slideSize.SlideOrientation = SlideOrientation.Landscape
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()
SlideTransition
Get the slide transition for the presentation. Read-only.
Declaration
ISlideShowTransition SlideTransition { get; }
Property Value
Type |
---|
ISlideShowTransition |
Examples
//Create a new presentation.
IPresentation ppDoc = Presentation.Create();
//Add a slide to the presentation.
ISlide slide = ppDoc.Slides.Add(SlideLayoutType.Blank);
//Add shape on the slide
IShape shape = slide.Shapes.AddShape(AutoShapeType.Diamond, 150, 150, 250, 150);
//Get the slide transition value
ISlideShowTransition transition = slide.SlideTransition;
//Add slide transition for slide
transition.TransitionEffect = TransitionEffect.Airplane;
//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 shape on the slide
Dim shape As IShape = slide.Shapes.AddShape(AutoShapeType.Diamond, 150, 150, 250, 150)
'Get the slide transition value
Dim transition As ISlideShowTransition = slide.SlideTransition
'Add slide transition for slide
transition.TransitionEffect = TransitionEffect.Airplane
'Save the presentation file
ppDoc.Save("Sample.pptx")
'Close the presentation file
ppDoc.Close()
Tables
Gets an ITables collection that represents the tables in a slide. Read-only.
Declaration
ITables Tables { get; }
Property Value
Type |
---|
ITables |
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 to hold table collection
ITables tables = slide.Tables;
//Add table to the slide
ITable table = tables.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");
//Give simple description to table shape
table.Description = "Table arrangement";
//Save the presentation
presentation.Save("Output.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 to hold table collection
Dim tables As ITables = slide.Tables
'Add table to the slide
Dim table As ITable = tables.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")
'Give simple description to table shape
table.Description = "Table arrangement"
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()
Timeline
Get the timeline(Animation) of the slide
Declaration
IAnimationTimeline Timeline { get; }
Property Value
Type |
---|
IAnimationTimeline |
Examples
// Create a new presentation.
IPresentation ppDoc = Presentation.Create();
// Add a slide to the presentation.
ISlide slide = ppDoc.Slides.Add(SlideLayoutType.Blank);
// Add shape on the slide
IShape shape = slide.Shapes.AddShape(AutoShapeType.Diamond, 150, 150, 250, 150);
// Get the timeline(Animation) of the slide
IAnimationTimeline timeLine = slide.Timeline;
// Add animation effect on the slide with shape
IEffect effect = timeLine.MainSequence.AddEffect(shape, EffectType.ChangeFillColor, EffectSubtype.None, EffectTriggerType.OnClick);
// 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 shape on the slide
Dim shape As IShape = slide.Shapes.AddShape(AutoShapeType.Diamond, 150, 150, 250, 150)
'Get the timeline(Animation) of the slide
Dim timeLine As IAnimationTimeLine = slide.TimeLine;
'Add animation effect on the slide with shape
Dim effect As IEffect = timeLine.MainSequence.AddEffect(shape, EffectType.ChangeFillColor, EffectSubtype.None, EffectTriggerType.OnClick)
'Save the presentation file
ppDoc.Save("Sample.pptx")
'Close the presentation file
ppDoc.Close()
Methods
Find(String, Boolean, Boolean)
Finds the text based on specified string, taking into the consideration of caseSensitive and wholeWord options.
Declaration
ITextSelection Find(string textToFind, bool caseSensitive, bool wholeWord)
Parameters
Type | Name | Description |
---|---|---|
System.String | textToFind | A text to find. |
System.Boolean | caseSensitive | Set to true to match the similar case text which specified in the |
System.Boolean | wholeWord | Set to true to match the whole word text which specified in the |
Returns
Type | Description |
---|---|
ITextSelection | The ITextSelection that contains the found text in the document. |
Examples
//Create a new presentation instance.
IPresentation presentation = Presentation.Create();
//Add the slide into the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
// Add a text box to hold the list
IShape textBoxShape = slide.AddTextBox(65, 140, 410, 270);
// Add a new paragraph with a text
IParagraph paragraph = textBoxShape.TextBody.AddParagraph("Hello World");
// Finds the text from the Presentation document
ITextSelection textSelection = slide.Find("World", false, false);
// Gets the found text containing text parts
foreach (ITextPart textPart in textSelection.GetTextParts())
{
//Sets Bold property
textPart.Font.Bold = true;
}
//Save the presentation
presentation.Save("Output.pptx");
//Close the presentation
presentation.Close();
'Creates a presentation.
Dim presentation As IPresentation = Presentation.Create()
'Add the slide into the presentation
Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
'Add a text box to hold the list
Dim textBoxShape As IShape = slide.AddTextBox(65, 140, 410, 270)
'Add a new paragraph with a text
Dim paragraph As IParagraph = textBoxShape.TextBody.AddParagraph("Hello World")
'Finds the text from the Presentation document
Dim textSelection As ITextSelection = slide.Find("World", False, False)
'Gets the text parts from the selection
For Each textPart As ITextPart In textSelection.GetTextParts()
textPart.Font.Bold = True
Next
presentation.Save("Output.pptx")
presentation.Close()
Find(Regex)
Finds the first occurrence of text that matches the specified Regex pattern.
Declaration
ITextSelection Find(Regex pattern)
Parameters
Type | Name | Description |
---|---|---|
System.Text.RegularExpressions.Regex | pattern | The System.Text.RegularExpressions.Regex used to find the text. |
Returns
Type | Description |
---|---|
ITextSelection | The ITextSelection> that contains the found text in the document. |
Examples
//Opens an existing presentation.
using (IPresentation pptxDoc = Presentation.Open("Input.pptx"))
{
// Create a regex pattern to find a text that starts with 'H' and ends with 'o'.
Regex regex = new Regex("H.+?o");
//Find the first occurrence of a specified regular expression.
ITextSelection textSelection = pptxDoc.Slides[0].Find(regex);
//Gets the found text as single text part
ITextPart textPart = textSelection.GetAsOneTextPart();
//Replace the text
textPart.Text = "Replaced text";
//Saves the Presentation
pptxDoc.Save("Output.pptx");
}
'Opens an existing presentation.
Using pptxDoc As IPresentation = Presentation.Open("Input.pptx")
' Create a regex pattern to find a text that starts with 'H' and ends with 'o'.
Dim regex As Regex = New Regex("H.+?o")
'Find the first occurrence of a specified regular expression.
Dim textSelection As ITextSelection = pptxDoc.Slides(0).Find(regex)
'Gets the found text as single text part
Dim textPart As ITextPart = textSelection.GetAsOneTextPart()
'Replace the text
textPart.Text = "Replaced text"
'Saves the Presentation
pptxDoc.Save("Output.pptx")
End Using
FindAll(String, Boolean, Boolean)
Finds and returns all entries of the specified string, taking into the consideration of caseSensitive and wholeWord options.
Declaration
ITextSelection[] FindAll(string textToFind, bool caseSensitive, bool wholeWord)
Parameters
Type | Name | Description |
---|---|---|
System.String | textToFind | A text to find. |
System.Boolean | caseSensitive | Set to true to match the similar case text which specified in the |
System.Boolean | wholeWord | Set to true to match the whole word text which specified in the |
Returns
Type | Description |
---|---|
ITextSelection[] | The ITextSelection collection that contains all the entries of the found text in the document. |
Examples
//Create a new presentation instance.
IPresentation presentation = Presentation.Create();
//Add the slide into the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
// Add a text box to hold the list
IShape textBoxShape = slide.AddTextBox(65, 140, 410, 270);
// Add a new paragraph with a text
IParagraph paragraph = textBoxShape.TextBody.AddParagraph("Hello World");
// Finds the text from the mentioned slide
ITextSelection[] textSelections = slide.FindAll("World", false, false);
foreach (ITextSelection textSelection in textSelections)
{
//Gets the found text as single text part
ITextPart textPart = textSelection.GetAsOneTextPart();
//Replace the text
textPart.Text = "Replaced text";
}
//Save the presentation
presentation.Save("Output.pptx");
//Close the presentation
presentation.Close();
'Creates a presentation.
Dim presentation As IPresentation = Presentation.Create()
'Add the slide into the presentation
Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Blank)
'Add a text box to hold the list
Dim textBoxShape As IShape = slide.AddTextBox(65, 140, 410, 270)
'Add a new paragraph with a text
Dim paragraph As IParagraph = textBoxShape.TextBody.AddParagraph("Hello World")
'Finds the text from the mentioned slide
Dim textSelections As ITextSelection() = slide.FindAll("World", False, False)
'Gets the found text as single text part and replace it
For Each textSelection As ITextSelection In textSelections
Dim textPart As ITextPart = textSelection.GetAsOneTextPart()
textPart.Text = "Replaced text"
Next
presentation.Save("Output.pptx")
presentation.Close()
FindAll(Regex)
Finds all occurrences of text that match the specified Regex pattern.
Declaration
ITextSelection[] FindAll(Regex pattern)
Parameters
Type | Name | Description |
---|---|---|
System.Text.RegularExpressions.Regex | pattern | The System.Text.RegularExpressions.Regex used to find the text. |
Returns
Type | Description |
---|---|
ITextSelection[] | The ITextSelection collection that contains all the entries of the found text in the document. |
Examples
//Opens an existing presentation.
using (IPresentation pptxDoc = Presentation.Open("Input.pptx"))
{
// Create a regex pattern to find a text that starts with 'H' and ends with 'o'.
Regex regex = new Regex("H.+?o");
//Finds all the occurrences of a specified regular expression.
ITextSelection[] textSelections = pptxDoc.Slides[0].FindAll(regex);
foreach (ITextSelection textSelection in textSelections)
{
//Gets the found text as single text part
ITextPart textPart = textSelection.GetAsOneTextPart();
//Replace the text
textPart.Text = "Replaced text";
}
//Saves the Presentation
pptxDoc.Save("Output.pptx");
}
'Opens an existing presentation.
Using pptxDoc As IPresentation = Presentation.Open("Input.pptx")
' Create a regex pattern to find a text that starts with 'H' and ends with 'o'.
Dim regex As Regex = New Regex("H.+?o")
'Finds all the occurrences of a specified regular expression.
Dim textSelections As ITextSelection() = pptxDoc.Slides(0).FindAll(regex)
For Each textSelection As ITextSelection In textSelections
'Gets the found text as single text part
Dim textPart As ITextPart = textSelection.GetAsOneTextPart()
'Replace the text
textPart.Text = "Replaced text"
Next
'Saves the Presentation
pptxDoc.Save("Output.pptx")
End Using