Interface IPresentation
Represents the PowerPoint presentation.
Namespace: Syncfusion.Presentation
Assembly: Syncfusion.Presentation.UWP.dll
Syntax
public interface IPresentation : IDisposable
Properties
BuiltInDocumentProperties
Gets an IBuiltInDocumentProperties instance that represents the built in document properties of presentation. Read-only.
Declaration
IBuiltInDocumentProperties BuiltInDocumentProperties { get; }
Property Value
Type |
---|
IBuiltInDocumentProperties |
Examples
//Create an instance for presentation.
IPresentation presentation = Presentation.Create();
//Retrieve the built-in document property, it is read only
IBuiltInDocumentProperties builtin = presentation.BuiltInDocumentProperties;
//Set the application name
builtin.ApplicationName = "Essential Presentation";
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Create an instance for presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Retrieve the built-in document property, it is read only
Dim builtin As IBuiltInDocumentProperties = presentation__1.BuiltInDocumentProperties
'Set the application name
builtin.ApplicationName = "Essential Presentation"
'Save the presentation
presentation__1.Save("Sample.pptx")
'Close the presentation
presentation__1.Close()
ChartToImageConverter
Gets the IOfficeChartToImageConverter instance.
Declaration
IOfficeChartToImageConverter ChartToImageConverter { get; set; }
Property Value
Type |
---|
IOfficeChartToImageConverter |
Remarks
Initialize the ChartToImageConverter in-order to convert the chart in presentation to image.
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Initialize the chart to image converter.
presentation.ChartToImageConverter = new ChartToImageConverter();
//Set the scaling mode for the chart.
presentation.ChartToImageConverter.ScalingMode = ScalingMode.Best;
//Add a blank slide for the chart.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add a chart to the slide.
IPresentationChart officeChart = slide.Charts.AddChart(100, 100, 600, 400);
//Set chart data
officeChart.ChartData.SetValue(1, 4, "Month");
officeChart.ChartData.SetValue(2, 4, "July");
officeChart.ChartData.SetValue(3, 4, "August");
officeChart.ChartData.SetValue(4, 4, "September");
officeChart.ChartData.SetValue(5, 4, "October");
officeChart.ChartData.SetValue(6, 4, "November");
officeChart.ChartData.SetValue(7, 4, "December");
officeChart.ChartData.SetValue(1, 1, "2013");
officeChart.ChartData.SetValue(2, 1, 35);
officeChart.ChartData.SetValue(3, 1, 37);
officeChart.ChartData.SetValue(4, 1, 30);
officeChart.ChartData.SetValue(5, 1, 29);
officeChart.ChartData.SetValue(6, 1, 25);
officeChart.ChartData.SetValue(7, 1, 30);
officeChart.ChartData.SetValue(1, 2, "2014");
officeChart.ChartData.SetValue(2, 2, 30);
officeChart.ChartData.SetValue(3, 2, 25);
officeChart.ChartData.SetValue(4, 2, 29);
officeChart.ChartData.SetValue(5, 2, 35);
officeChart.ChartData.SetValue(6, 2, 38);
officeChart.ChartData.SetValue(7, 2, 32);
officeChart.ChartData.SetValue(1, 3, "2015");
officeChart.ChartData.SetValue(2, 3, 35);
officeChart.ChartData.SetValue(3, 3, 37);
officeChart.ChartData.SetValue(4, 3, 30);
officeChart.ChartData.SetValue(5, 3, 50);
officeChart.ChartData.SetValue(6, 3, 25);
officeChart.ChartData.SetValue(7, 3, 30);
//Add chart serie.
IOfficeChartSerie serie1 = officeChart.Series.Add("2013");
//Set serie value.
serie1.Values = officeChart.ChartData[2, 1, 7, 1];
//Add chart serie.
IOfficeChartSerie serie2 = officeChart.Series.Add("2014");
//Set serie value.
serie2.Values = officeChart.ChartData[2, 2, 7, 2];
//Add chart serie.
IOfficeChartSerie serie3 = officeChart.Series.Add("2015");
//Set serie value.
serie3.Values = officeChart.ChartData[2, 3, 7, 3];
//Set category labels value for the primary category axis.
officeChart.PrimaryCategoryAxis.CategoryLabels = officeChart.ChartData[2, 4, 7, 4];
//Set the chart type.
officeChart.ChartType = OfficeChartType.Column_Clustered;
//Set the chart title.
officeChart.ChartTitle = "Mine Chart";
//Convert the chart to image.
System.Drawing.Image[] chartImages = presentation.RenderAsImages(Syncfusion.Drawing.ImageType.Metafile);
foreach (System.Drawing.Image image in chartImages)
{
//Save the image.
image.Save("ChartToImageConverter" + Guid.NewGuid() + ".png");
}
//Save the presentation.
presentation.Save("ChartToImageConverter.pptx");
//Close the presentation.
presentation.Close();
'Create a new presentation.
Dim presentation__1 As IPresentation = Presentation.Create()
'Initialize the chart to image converter.
presentation__1.ChartToImageConverter = New ChartToImageConverter()
'Set the scaling mode for the chart.
presentation__1.ChartToImageConverter.ScalingMode = ScalingMode.Best
'Add a blank slide for the chart.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add a chart to the slide.
Dim officeChart As IPresentationChart = slide.Charts.AddChart(100, 100, 600, 400)
'Set chart data
officeChart.ChartData.SetValue(1, 4, "Month")
officeChart.ChartData.SetValue(2, 4, "July")
officeChart.ChartData.SetValue(3, 4, "August")
officeChart.ChartData.SetValue(4, 4, "September")
officeChart.ChartData.SetValue(5, 4, "October")
officeChart.ChartData.SetValue(6, 4, "November")
officeChart.ChartData.SetValue(7, 4, "December")
officeChart.ChartData.SetValue(1, 1, "2013")
officeChart.ChartData.SetValue(2, 1, 35)
officeChart.ChartData.SetValue(3, 1, 37)
officeChart.ChartData.SetValue(4, 1, 30)
officeChart.ChartData.SetValue(5, 1, 29)
officeChart.ChartData.SetValue(6, 1, 25)
officeChart.ChartData.SetValue(7, 1, 30)
officeChart.ChartData.SetValue(1, 2, "2014")
officeChart.ChartData.SetValue(2, 2, 30)
officeChart.ChartData.SetValue(3, 2, 25)
officeChart.ChartData.SetValue(4, 2, 29)
officeChart.ChartData.SetValue(5, 2, 35)
officeChart.ChartData.SetValue(6, 2, 38)
officeChart.ChartData.SetValue(7, 2, 32)
officeChart.ChartData.SetValue(1, 3, "2015")
officeChart.ChartData.SetValue(2, 3, 35)
officeChart.ChartData.SetValue(3, 3, 37)
officeChart.ChartData.SetValue(4, 3, 30)
officeChart.ChartData.SetValue(5, 3, 50)
officeChart.ChartData.SetValue(6, 3, 25)
officeChart.ChartData.SetValue(7, 3, 30)
'Add chart serie.
Dim serie1 As IOfficeChartSerie = officeChart.Series.Add("2013")
'Set serie value.
serie1.Values = officeChart.ChartData(2, 1, 7, 1)
'Add chart serie.
Dim serie2 As IOfficeChartSerie = officeChart.Series.Add("2014")
'Set serie value.
serie2.Values = officeChart.ChartData(2, 2, 7, 2)
'Add chart serie.
Dim serie3 As IOfficeChartSerie = officeChart.Series.Add("2015")
'Set serie value.
serie3.Values = officeChart.ChartData(2, 3, 7, 3)
'Set category labels value for the primary category axis.
officeChart.PrimaryCategoryAxis.CategoryLabels = officeChart.ChartData(2, 4, 7, 4)
'Set the chart type.
officeChart.ChartType = OfficeChartType.Column_Clustered
'Set the chart title.
officeChart.ChartTitle = "Mine Chart"
'Convert the chart to image.
Dim chartImages As Image() = presentation__1.RenderAsImages(Syncfusion.Drawing.ImageType.Metafile)
For Each image As Image In chartImages
'Save the image.
image.Save("ChartToImageConverter" + Guid.NewGuid() + ".png")
Next
'Save the presentation.
presentation__1.Save("ChartToImageConverter.pptx")
'Close the presentation.
presentation__1.Close()
CustomDocumentProperties
Gets an ICustomDocumentProperties instance that represents the custom document properties of presentation. Read-only.
Declaration
ICustomDocumentProperties CustomDocumentProperties { get; }
Property Value
Type |
---|
ICustomDocumentProperties |
Examples
//Create a new presentation
IPresentation presentation = Presentation.Create();
//Retrieve the custom document properties.
ICustomDocumentProperties customDocumentProperties = presentation.CustomDocumentProperties;
//Add a new custom document property
customDocumentProperties.Add("Property1");
//Set a Boolean value.
customDocumentProperties["Property1"].Boolean = true;
//Add a new custom document property
customDocumentProperties.Add("Property2");
//Set a date time.
customDocumentProperties["Property2"].DateTime = DateTime.Now;
//Save the presentation
presentation.Save("CustomProperty.pptx");
//Close the presentation
presentation.Close();
'Create a new presentation
Dim presentation__1 As IPresentation = Presentation.Create()
'Retrieve the custom document properties.
Dim customDocumentProperties As ICustomDocumentProperties = presentation__1.CustomDocumentProperties
'Add a new custom document property
customDocumentProperties.Add("Property1")
'Set a Boolean value.
customDocumentProperties("Property1").[Boolean] = True
'Add a new custom document property
customDocumentProperties.Add("Property2")
'Set a date time.
customDocumentProperties("Property2").DateTime = DateTime.Now
'Save the presentation
presentation__1.Save("CustomProperty.pptx")
'Close the presentation
presentation__1.Close()
Final
Gets or sets a value indicating whether the IPresentation instance is marked as final.
Declaration
bool Final { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
//Create an instance for PowerPoint presentation
IPresentation pptxDoc = Presentation.Create();
//Add slide to the presentation
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Mark the presentation as final
pptxDoc.Final = true;
//Save the presentation
pptxDoc.Save("Sample.pptx");
//Close the presentation
pptxDoc.Close();
'Create an instance for PowerPoint presentation
Dim pptxDoc As IPresentation = Presentation.Create()
'Add slide to the presentation
Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
'Mark the presentation as final
pptxDoc.Final = True
'Save the presentation
pptxDoc.Save("Sample.pptx")
'Close the presentation
pptxDoc.Close()
FirstSlideNumber
Gets or sets the first slide number of the PowerPoint Presentation. The default value is 1.
Declaration
int FirstSlideNumber { get; set; }
Property Value
Type |
---|
System.Int32 |
Remarks
First slide number is the starting slide number of presentation, and this API allows to set the first slide number from 0 to 9999.
Examples
//Creates a new PowerPint Presentation.
using (IPresentation presentation = Presentation.Create())
{
//Sets the first slide number of the PowerPoint Presentation.
presentation.FirstSlideNumber = 5;
//Adds slide to the PowerPoint.
ISlide slide1 = presentation.Slides.Add(SlideLayoutType.TitleAndContent);
//Adds slide to the PowerPoint.
ISlide slide2 = presentation.Slides.Add(SlideLayoutType.TitleAndContent);
//Adds slide to the PowerPoint.
ISlide slide3 = presentation.Slides.Add(SlideLayoutType.TitleAndContent);
//Gets the first slide slidenumber.
int firstSlideNumber = slide1.SlideNumber;
//Gets the second slide slidenumber.
int secondSlideNumber = slide2.SlideNumber;
//Saves the PowerPoint Presentation.
presentation.Save("Output.pptx");
}
'Creates a PowerPoint instance
Using pptxDoc As IPresentation = Presentation.Create()
'Sets the first slide number of the PowerPoint Presentation.
pptxDoc.FirstSlideNumber = 5
'Adds a slide to the PowerPoint presentation
Dim slide1 As ISlide = pptxDoc.Slides.Add(SlideLayoutType.TitleAndContent)
'Adds a slide to the PowerPoint presentation
Dim slide2 As ISlide = pptxDoc.Slides.Add(SlideLayoutType.TitleAndContent)
'Adds a slide to the PowerPoint presentation
Dim slide3 As ISlide = pptxDoc.Slides.Add(SlideLayoutType.TitleAndContent)
'Gets the first slide slidenumber.
Dim firstSlideNumber As Integer = slide1.SlideNumber
'Gets the second slide slidenumber.
Dim secondSlideNumber As Integer = slide2.SlideNumber
'Saves the Presentation to the file system.
pptxDoc.Save("Output.pptx")
End Using
HasMacros
Gets whether the presentation has macros. Read-only.
Declaration
bool HasMacros { get; }
Property Value
Type |
---|
System.Boolean |
Examples
//Opens an existing macro enabled PowerPoint presentation
IPresentation pptxDoc = Presentation.Open("Sample.PPTM");
//Checks whether the presentation has macros and then removes them
if (pptxDoc.HasMacros)
pptxDoc.RemoveMacros();
//Saves the presentation
pptxDoc.Save("Output.pptx");
//Closes the presentation
pptxDoc.Close();
'Opens an existing macro enabled PowerPoint presentation
Dim pptxDoc As IPresentation = Presentation.Open("Sample.PPTM")
'Checks whether the presentation has macros and then removes them
If pptxDoc.HasMacros Then
pptxDoc.RemoveMacros()
End If
'Saves the presentation
pptxDoc.Save("Output.pptx")
'Closes the presentation
pptxDoc.Close()
IsWriteProtected
Gets whether the presentation is write Protected. Read-only.
Declaration
bool IsWriteProtected { get; }
Property Value
Type |
---|
System.Boolean |
Examples
//Create an instance for presentation
IPresentation presentation = Presentation.Open("Sample.pptx");
//Check whether the presentation is write protected.
if (presentation.IsWriteProtected)
{
//Removes the write protection from presentation instance
presentation.RemoveWriteProtection();
}
//Save the presentation
presentation.Save("Output.pptx");
//Close the presentation.
presentation.Close();
'Create an instance for presentation
Dim presentation As IPresentation = Presentation.Open("Sample.pptx")
'Check whether the presentation is write protected.
if (presentation.IsWriteProtected)
{
'Removes the write protection from presentation instance
presentation.RemoveWriteProtection()
}
'Save the presentation
presentation.Save("Output.pptx")
'Close the presentation.
presentation.Close()
Masters
Declaration
IMasterSlides Masters { get; }
Property Value
Type |
---|
IMasterSlides |
Sections
Returns a collection of ISection instances. Read-only.
Declaration
ISections Sections { get; }
Property Value
Type |
---|
ISections |
Examples
//Creates a PowerPoint presentation
IPresentation presentation = Presentation.Create();
//Adds a section to the PowerPoint presentation
ISection section = presentation.Sections.Add();
//Sets a name to the created section
section.Name = "SectionDemo";
//Adds a slide to the created section
ISlide slide = section.AddSlide(SlideLayoutType.Blank);
//Adds a text box to the slide
slide.AddTextBox(10, 10, 100, 100).TextBody.AddParagraph("Slide in SectionDemo");
//Saves the PowerPoint presentation
presentation.Save("Sample.pptx");
//Close the presentation
presentation.Close();
'Creates a PowerPoint presentation
Dim presentation__1 As IPresentation = Presentation.Create()
'Adds a section to the PowerPoint presentation
Dim section As ISection = presentation__1.Sections.Add()
'Sets a name to the created section
section.Name = "SectionDemo"
'Adds a slide to the created section
Dim slide As ISlide = section.AddSlide(SlideLayoutType.Blank)
'Adds a text box to the slide
slide.AddTextBox(10, 10, 100, 100).TextBody.AddParagraph("Slide in SectionDemo")
'Saves the PowerPoint presentation
presentation__1.Save("Sample.pptx")
'Close the Presentation instance
presentation__1.Close()
Slides
Gets the slide collection in the presentation. Read-only.
Declaration
ISlides Slides { get; }
Property Value
Type |
---|
ISlides |
Examples
//Open a presentation.
IPresentation presentation = Presentation.Open("Input.pptx");
//Retrieve the slide collection, it is read only
ISlides slides = presentation.Slides;
//Add a slide to the presentation
ISlide slide = slides[0];
//Create instance for slide background
IBackground background = slide.Background;
//Set the fill type for background as Pattern fill
background.Fill.FillType = FillType.Pattern;
//Set the pattern
background.Fill.PatternFill.Pattern = PatternFillType.DashedHorizontal;
//set the fore color of pattern
background.Fill.PatternFill.ForeColor = ColorObject.Lavender;
//Set the back color of pattern
background.Fill.PatternFill.BackColor = ColorObject.Brown;
//Save the presentation
presentation.Save("Output.pptx");
//Close the presentation
presentation.Close();
'Open a presentation.
Dim presentation__1 As IPresentation = Presentation.Open("Input.pptx")
'Retrieve the slide collection, it is read only
Dim slides As ISlides = presentation__1.Slides
'Add a slide to the presentation
Dim slide As ISlide = slides(0)
'Create instance for slide background
Dim background As IBackground = slide.Background
'Set the fill type for background as Pattern fill
background.Fill.FillType = FillType.Pattern
'Set the pattern
background.Fill.PatternFill.Pattern = PatternFillType.DashedHorizontal
'set the fore color of pattern
background.Fill.PatternFill.ForeColor = ColorObject.Lavender
'Set the back color of pattern
background.Fill.PatternFill.BackColor = ColorObject.Brown
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()
Methods
Clone()
Creates an independent copy of IPresentation instance.
Declaration
IPresentation Clone()
Returns
Type | Description |
---|---|
IPresentation | Returns the cloned presentation instance. |
Examples
//Create an instance for presentation
IPresentation presentation = Presentation.Create();
//Add a new slide of comparison slide layout type.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Comparison);
//Clone the entire presentation.
IPresentation presentationClone = presentation.Clone();
//Add a new slide of title layout type.
slide = presentationClone.Slides.Add(SlideLayoutType.Title);
//Add an auto shape of regular pentagon auto shape type.
slide.Shapes.AddShape(AutoShapeType.RegularPentagon, 10, 20, 300, 400);
//Save the cloned presentation
presentationClone.Save("Sample.pptx");
//Close the presentation.
presentation.Close();
//Close the cloned presentation.
presentationClone.Close();
'Create an instance for presentation
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a new slide of comparison slide layout type.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Comparison)
'Clone the entire presentation.
Dim presentationClone As IPresentation = presentation__1.Clone()
'Add a new slide of title layout type.
slide = presentationClone.Slides.Add(SlideLayoutType.Title)
'Add an auto shape of regular pentagon auto shape type.
slide.Shapes.AddShape(AutoShapeType.RegularPentagon, 10, 20, 300, 400)
'Save the cloned presentation
presentationClone.Save("Sample.pptx")
'Close the presentation.
presentation__1.Close()
'Close the cloned presentation.
presentationClone.Close()
Close()
Releases any resources associated with the presentation instance.
Declaration
void Close()
Examples
//Create a new presentation.
IPresentation presentation = Presentation.Create();
//Add a new slide of comparison slide layout type.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Comparison);
//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 new slide of comparison slide layout type.
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Comparison)
'Save the presentation.
presentation__1.Save("Sample.pptx")
'Close the presentation.
presentation__1.Close()
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 = presentation.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 = presentation.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.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.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 all the text from the Presentation document
ITextSelection[] textSelections = presentation.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 Presentation document
Dim textSelections As ITextSelection() = presentation.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.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.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
RemoveMacros()
Removes the macros from the presentation instance.
Declaration
void RemoveMacros()
Examples
//Opens an existing macro enabled PowerPoint presentation
IPresentation pptxDoc = Presentation.Open("Sample.PPTM");
//Checks whether the presentation has macros and then removes them
if (pptxDoc.HasMacros)
pptxDoc.RemoveMacros();
//Saves the presentation
pptxDoc.Save("Output.pptx");
//Closes the presentation
pptxDoc.Close();
'Opens an existing macro enabled PowerPoint presentation
Dim pptxDoc As IPresentation = Presentation.Open("Sample.PPTM")
'Checks whether the presentation has macros and then removes them
If pptxDoc.HasMacros Then
pptxDoc.RemoveMacros()
End If
'Saves the presentation
pptxDoc.Save("Output.pptx")
'Closes the presentation
pptxDoc.Close()
RemoveWriteProtection()
Removes the write Protection from presentation instance
Declaration
void RemoveWriteProtection()
Examples
//Create an instance for presentation
IPresentation presentation = Presentation.Open("Sample.pptx");
//Check whether the presentation is write protected.
if (presentation.IsWriteProtected)
{
//Removes the write protection from presentation instance
presentation.RemoveWriteProtection();
}
//Save the presentation
presentation.Save("Output.pptx");
//Close the presentation.
presentation.Close();
'Create an instance for presentation
Dim presentation As IPresentation = Presentation.Open("Sample.pptx")
'Check whether the presentation is write protected.
if (presentation.IsWriteProtected)
{
//Removes the write protection from presentation instance
presentation.RemoveWriteProtection()
}
'Save the presentation
presentation.Save("Output.pptx")
'Close the presentation.
presentation.Close()
Save(Stream)
Declaration
void Save(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream |
Remarks
At present, the Essential Presentation library only supports the PPTX file format.
Examples
//Create instance for memory stream
MemoryStream fileStream = new MemoryStream();
//Open a presentation
IPresentation presentation = Presentation.Create();
//Add slide to the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add table to the slide
ITable table = slide.Shapes.AddTable(3, 3, 100, 120, 300, 200);
//Save the presentation using stream
presentation.Save(fileStream);
//Close the presentation.
presentation.Close();
//Dispose the file stream
fileStream.Dispose();
'Create instance for memory stream
Dim fileStream As New MemoryStream()
'Open a presentation
Dim presentation__1 As IPresentation = Presentation.Create()
'Add slide to the presentation
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add table to the slide
Dim table As ITable = slide.Shapes.AddTable(3, 3, 100, 120, 300, 200)
'Save the presentation using stream
presentation__1.Save(fileStream)
'Close the presentation.
presentation__1.Close()
'Dispose the file stream
fileStream.Dispose()
SaveAsync(Stream)
Saves the presentation into stream.
Declaration
Task<bool> SaveAsync(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream |
Returns
Type |
---|
System.Threading.Tasks.Task<System.Boolean> |
SaveAsync(StorageFile)
Saves the document into data stream.
Declaration
Task<bool> SaveAsync(StorageFile file)
Parameters
Type | Name | Description |
---|---|---|
Windows.Storage.StorageFile | file | The Windows.Storage.StorageFile for the presentation to save. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | A task that represents the asynchronous save operation. |
SetWriteProtection(String)
Sets the write protection for the presentation instance
Declaration
void SetWriteProtection(string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | password | Password to enforce protection. |
Remarks
Maximum length of password should be 15. If it exceeds 15, first 15 characters will be considered for protection, remaining will be ignored.
Examples
//Create an instance for presentation
IPresentation presentation = Presentation.Create();
//Add a new slide of comparison slide layout type.
ISlide slide = presentation.Slides.Add(SlideLayoutType.Comparison);
//Add an auto shape of regular pentagon auto shape type.
slide.Shapes.AddShape(AutoShapeType.RegularPentagon, 10, 20, 300, 400);
//Set the write protection for Presentation instance with password.
presentation.SetWriteProtection("MYPASSWORD");
//Save the presentation
presentation.Save("Sample.pptx");
//Close the presentation.
presentation.Close();
'Create an instance for presentation
Dim presentation As IPresentation = Presentation.Create()
'Add a new slide of comparison slide layout type.
Dim slide As ISlide = presentation.Slides.Add(SlideLayoutType.Comparison)
'Add an auto shape of regular pentagon auto shape type.
slide.Shapes.AddShape(AutoShapeType.RegularPentagon, 10, 20, 300, 400)
'Set the write protection for Presentation instance with password.
presentation.SetWriteProtection("MYPASSWORD")
'Save the presentation
presentation.Save("Sample.pptx")
'Close the presentation.
presentation.Close()