From 6cb8a39840451b7b08cb3683c288553ba53309e8 Mon Sep 17 00:00:00 2001 From: Viswajith-SF4658 Date: Fri, 31 Jul 2026 13:37:35 +0530 Subject: [PATCH 1/4] Task 1044136: Revamp User Guide Documentation in PowerPoint presentation library --- .../NET/Working-with-NotesSlide.md | 115 +++++++++++------- 1 file changed, 71 insertions(+), 44 deletions(-) diff --git a/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md b/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md index 7d6a495d82..a09fde3466 100644 --- a/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md +++ b/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md @@ -9,11 +9,15 @@ keywords: Working with Notes # Working with PowerPoint Notes -Notes are the contents associated with each slide and are visible only to the presenter when monitors are shared in “Presenter View”. It shows hint for the speaker, so it is often called as “Speaker Notes”. The presenter can optionally add key points to notes. You can add and modify the notes in your slide using Essential® Presentation library. +Notes are the contents associated with each slide and are visible only to the presenter when monitors are shared in “Presenter View”. They show hints for the speaker, so they are often called “Speaker Notes”. The presenter can optionally add key points to notes. You can add and modify the notes in your slide using Syncfusion® Presentation library. + +## Prerequisites + +Before you begin, make sure the following NuGet package is installed in your application. For more information on the assemblies and NuGet packages required for your target platform, refer to [Assemblies Required](Assemblies-Required) and [NuGet Packages Required](NuGet-Packages-Required). ## Adding Notes to a Slide -The below code example demonstrates how to create a Notes in a PowerPoint Slide. +The following code example demonstrates how to add notes to a PowerPoint slide. {% tabs %} @@ -27,9 +31,10 @@ ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); INotesSlide notesSlide = slide.AddNotesSlide(); //Adds text content into the Notes Slide. notesSlide.NotesTextBody.AddParagraph("Notes content"); -//Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream(OutputFileName, FileMode.Create); -pptxDoc.Save(outputStream); +//Saves the Presentation to the file system. +pptxDoc.Save("PresentationWithNotesSlide.pptx"); +//Closes the Presentation. +pptxDoc.Close(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} @@ -43,6 +48,8 @@ INotesSlide notesSlide = slide.AddNotesSlide(); notesSlide.NotesTextBody.AddParagraph("Notes content"); //Saves Presentation with specified file name with extension. pptxDoc.Save("PresentationWithNotesSlide.pptx"); +//Closes the Presentation. +pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} @@ -56,15 +63,19 @@ Dim notesSlide As INotesSlide = slide.AddNotesSlide() notesSlide.NotesTextBody.AddParagraph("Notes content") 'Saves Presentation with specified file name with extension. pptxDoc.Save("PresentationWithNotesSlide.pptx") +'Closes the Presentation. +pptxDoc.Close() {% endhighlight %} {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Add-notes-to-PowerPoint-slide). -## Adding Text into the Notes +N> `AddNotesSlide()` returns the newly created `INotesSlide` for the specified slide. If a notes slide already exists for that slide, the existing notes slide is returned. The notes slide can also be accessed through the `slide.NotesSlide` property. -The following code example demonstrates how to add a text in a Notes. +## Adding Text into the Notes + +The following code example demonstrates how to add formatted text to notes. {% tabs %} @@ -76,20 +87,21 @@ IPresentation pptxDoc = Presentation.Create(); ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); //Adds new notes slide in the specified slide. INotesSlide notesSlide = slide.AddNotesSlide(); -//Adds Paragraph into the text body. +//Adds a paragraph into the text body. IParagraph paragraph = notesSlide.NotesTextBody.AddParagraph(); -//Adds text part into the Paragraph. +//Adds a text part into the paragraph. ITextPart textPart = paragraph.AddTextPart(); textPart.Text = "The notes slide represents the contents and key notes of the corresponding slide. It is more useful when we use Presenter View while presenting the seminars through SlideShow."; //Sets Bold format for text content. -textPart.Font.Bold=true; -// Sets font style using font name. +textPart.Font.Bold = true; +//Sets font style using font name. textPart.Font.FontName = "Times New Roman"; -// Sets text content size using FontSize property. +//Sets text content size using FontSize property. textPart.Font.FontSize = 20; -//Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream(OutputFileName, FileMode.Create); -pptxDoc.Save(outputStream); +//Saves the Presentation to the file system. +pptxDoc.Save("PresentationWithNotesText.pptx"); +//Closes the Presentation. +pptxDoc.Close(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} @@ -99,19 +111,21 @@ IPresentation pptxDoc = Presentation.Create(); ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); //Adds new notes slide in the specified slide. INotesSlide notesSlide = slide.AddNotesSlide(); -//Adds Paragraph into the text body. +//Adds a paragraph into the text body. IParagraph paragraph = notesSlide.NotesTextBody.AddParagraph(); -//Adds text part into the Paragraph. +//Adds a text part into the paragraph. ITextPart textPart = paragraph.AddTextPart(); textPart.Text = "The notes slide represents the contents and key notes of the corresponding slide. It is more useful when we use Presenter View while presenting the seminars through SlideShow."; //Sets Bold format for text content. -textPart.Font.Bold=true; -// Sets font style using font name. +textPart.Font.Bold = true; +//Sets font style using font name. textPart.Font.FontName = "Times New Roman"; -// Sets text content size using FontSize property. +//Sets text content size using FontSize property. textPart.Font.FontSize = 20; //Saves Presentation with specified file name with extension. -pptxDoc.Save("PresentationWithNotesSlide.pptx"); +pptxDoc.Save("PresentationWithNotesText.pptx"); +//Closes the Presentation. +pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} @@ -121,9 +135,9 @@ Dim pptxDoc As IPresentation = Presentation.Create() Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank) 'Adds new notes slide in the specified slide. Dim notesSlide As INotesSlide = slide.AddNotesSlide() -'Adds Paragraph into the text body. +'Adds a paragraph into the text body. Dim paragraph As IParagraph = notesSlide.NotesTextBody.AddParagraph() -'Adds text part into the Paragraph. +'Adds a text part into the paragraph. Dim textPart As ITextPart = paragraph.AddTextPart() textPart.Text = "The notes slide represents the contents and key notes of the corresponding slide. It is more useful when we use Presenter View while presenting the seminars through SlideShow." 'Sets Bold format for text content. @@ -133,16 +147,20 @@ textPart.Font.FontName = "Times New Roman" 'Sets text content size using FontSize property. textPart.Font.FontSize = 20 'Saves Presentation with specified file name with extension. -pptxDoc.Save("PresentationWithNotesSlide.pptx") +pptxDoc.Save("PresentationWithNotesText.pptx") +'Closes the Presentation. +pptxDoc.Close() {% endhighlight %} {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Add-text-in-notes). -## Adding a numbered list to Notes +N> In addition to `Bold`, `FontName`, and `FontSize`, the `ITextPart.Font` property exposes formatting options such as `Italic`, `Underline`, `FontColor`, `HighlightColor`, `StrikeThrough`, `BaselineAlignment`, and `FontScript`. For the full list of members, refer to the [ITextPart API reference](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextPart.html). -The following code example demonstrates how to create simple numbered list as Notes. +## Adding a Numbered List to Notes + +The following code example demonstrates how to create a simple numbered list as notes. {% tabs %} @@ -193,8 +211,7 @@ paragraph.FirstLineIndent = -20; // Sets the bullet character size. Here, 100 means 100% of its text. Possible values can range from 25 to 400. paragraph.ListFormat.Size = 100; //Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream(OutputFileName, FileMode.Create); -pptxDoc.Save(outputStream); +pptxDoc.Save(OutputFileName); //Closes the Presentation pptxDoc.Close(); {% endhighlight %} @@ -305,48 +322,58 @@ pptxDoc.Close() You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Create-numbered-list-in-notes-slide). + ## Removing Notes from a Slide -The below code example demonstrates how to remove a Notes from a PowerPoint Slide. +The following code example demonstrates how to remove the notes slide from a PowerPoint slide. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PowerPoint-Examples/master/Notes/Remove-notes-from-slide/.NET/Remove-notes-from-slide/Program.cs" %} -//Loads or open an PowerPoint Presentation -FileStream inputStream = new FileStream(inputFileName,FileMode.Open); -IPresentation pptxDoc = Presentation.Open(inputStream); -//Gets instance of the first slide from the Presentation. +//Opens an existing PowerPoint presentation. +IPresentation pptxDoc = Presentation.Open("Sample.pptx"); +//Gets the instance of the first slide from the presentation. ISlide slide = pptxDoc.Slides[0] as ISlide; -//Removes Notes Slide from a corresponding slide. +//Removes the notes slide from the corresponding slide. slide.RemoveNotesSlide(); -//Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream(OutputFileName, FileMode.Create); -pptxDoc.Save(outputStream); +//Saves the Presentation to the file system. +pptxDoc.Save("PresentationWithNotesSlide.pptx"); +//Closes the Presentation. +pptxDoc.Close(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} //Opens an existing PowerPoint presentation. IPresentation pptxDoc = Presentation.Open("Sample.pptx"); -//Gets instance of the first slide from the Presentation. +//Gets the instance of the first slide from the presentation. ISlide slide = pptxDoc.Slides[0] as ISlide; -//Removes Notes Slide from a corresponding slide. +//Removes the notes slide from the corresponding slide. slide.RemoveNotesSlide(); -//Saves Presentation with specified file name with extension. +//Saves the Presentation with the specified file name and extension. pptxDoc.Save("PresentationWithNotesSlide.pptx"); +//Closes the Presentation. +pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} 'Opens an existing PowerPoint presentation. Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx") -'Gets instance of the first slide from the Presentation. +'Gets the instance of the first slide from the presentation. Dim slide As ISlide = TryCast(pptxDoc.Slides(0), ISlide) -'Removes Notes Slide from a corresponding slide. +'Removes the notes slide from the corresponding slide. slide.RemoveNotesSlide() -'Saves Presentation with specified file name with extension. +'Saves the Presentation with the specified file name and extension. pptxDoc.Save("PresentationWithNotesSlide.pptx") +'Closes the Presentation. +pptxDoc.Close() {% endhighlight %} {% endtabs %} -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Remove-notes-from-slide). \ No newline at end of file +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Remove-notes-from-slide). + +## See Also + +- [Working with Comments](Comments) +- [Working with Paragraphs](./Working-with-paragraphs) \ No newline at end of file From 0e1ba421299e4989809588e11b0e47b7422d1c0e Mon Sep 17 00:00:00 2001 From: Viswajith-SF4658 Date: Fri, 31 Jul 2026 16:54:43 +0530 Subject: [PATCH 2/4] Reverted few changes for CI --- .../NET/Working-with-NotesSlide.md | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md b/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md index a09fde3466..394e430faf 100644 --- a/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md +++ b/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md @@ -9,15 +9,11 @@ keywords: Working with Notes # Working with PowerPoint Notes -Notes are the contents associated with each slide and are visible only to the presenter when monitors are shared in “Presenter View”. They show hints for the speaker, so they are often called “Speaker Notes”. The presenter can optionally add key points to notes. You can add and modify the notes in your slide using Syncfusion® Presentation library. - -## Prerequisites - -Before you begin, make sure the following NuGet package is installed in your application. For more information on the assemblies and NuGet packages required for your target platform, refer to [Assemblies Required](Assemblies-Required) and [NuGet Packages Required](NuGet-Packages-Required). +Notes are the contents associated with each slide and are visible only to the presenter when monitors are shared in “Presenter View”. It shows hint for the speaker, so it is often called as “Speaker Notes”. The presenter can optionally add key points to notes. You can add and modify the notes in your slide using Essential® Presentation library. ## Adding Notes to a Slide -The following code example demonstrates how to add notes to a PowerPoint slide. +The below code example demonstrates how to create a Notes in a PowerPoint Slide. {% tabs %} @@ -71,11 +67,9 @@ pptxDoc.Close() You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Add-notes-to-PowerPoint-slide). -N> `AddNotesSlide()` returns the newly created `INotesSlide` for the specified slide. If a notes slide already exists for that slide, the existing notes slide is returned. The notes slide can also be accessed through the `slide.NotesSlide` property. - -## Adding Text into the Notes +## Adding Text into the Notes -The following code example demonstrates how to add formatted text to notes. +The following code example demonstrates how to add a text in a Notes. {% tabs %} @@ -156,11 +150,9 @@ pptxDoc.Close() You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Add-text-in-notes). -N> In addition to `Bold`, `FontName`, and `FontSize`, the `ITextPart.Font` property exposes formatting options such as `Italic`, `Underline`, `FontColor`, `HighlightColor`, `StrikeThrough`, `BaselineAlignment`, and `FontScript`. For the full list of members, refer to the [ITextPart API reference](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextPart.html). +## Adding a numbered list to Notes -## Adding a Numbered List to Notes - -The following code example demonstrates how to create a simple numbered list as notes. +The following code example demonstrates how to create simple numbered list as Notes. {% tabs %} @@ -371,9 +363,4 @@ pptxDoc.Close() {% endtabs %} -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Remove-notes-from-slide). - -## See Also - -- [Working with Comments](Comments) -- [Working with Paragraphs](./Working-with-paragraphs) \ No newline at end of file +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Remove-notes-from-slide). \ No newline at end of file From dcf8c62a56d005a832368396f8d9eaa585acb878 Mon Sep 17 00:00:00 2001 From: Viswajith-SF4658 Date: Fri, 31 Jul 2026 17:15:11 +0530 Subject: [PATCH 3/4] reverted changes for CI run --- .../NET/Working-with-NotesSlide.md | 92 ++++++++----------- 1 file changed, 39 insertions(+), 53 deletions(-) diff --git a/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md b/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md index 394e430faf..2da0c9d783 100644 --- a/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md +++ b/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md @@ -11,7 +11,7 @@ keywords: Working with Notes Notes are the contents associated with each slide and are visible only to the presenter when monitors are shared in “Presenter View”. It shows hint for the speaker, so it is often called as “Speaker Notes”. The presenter can optionally add key points to notes. You can add and modify the notes in your slide using Essential® Presentation library. -## Adding Notes to a Slide +## Adding Notes to a Slides The below code example demonstrates how to create a Notes in a PowerPoint Slide. @@ -27,10 +27,9 @@ ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); INotesSlide notesSlide = slide.AddNotesSlide(); //Adds text content into the Notes Slide. notesSlide.NotesTextBody.AddParagraph("Notes content"); -//Saves the Presentation to the file system. -pptxDoc.Save("PresentationWithNotesSlide.pptx"); -//Closes the Presentation. -pptxDoc.Close(); +//Save the PowerPoint Presentation as stream +FileStream outputStream = new FileStream(OutputFileName, FileMode.Create); +pptxDoc.Save(outputStream); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} @@ -44,8 +43,6 @@ INotesSlide notesSlide = slide.AddNotesSlide(); notesSlide.NotesTextBody.AddParagraph("Notes content"); //Saves Presentation with specified file name with extension. pptxDoc.Save("PresentationWithNotesSlide.pptx"); -//Closes the Presentation. -pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} @@ -59,8 +56,6 @@ Dim notesSlide As INotesSlide = slide.AddNotesSlide() notesSlide.NotesTextBody.AddParagraph("Notes content") 'Saves Presentation with specified file name with extension. pptxDoc.Save("PresentationWithNotesSlide.pptx") -'Closes the Presentation. -pptxDoc.Close() {% endhighlight %} {% endtabs %} @@ -81,21 +76,20 @@ IPresentation pptxDoc = Presentation.Create(); ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); //Adds new notes slide in the specified slide. INotesSlide notesSlide = slide.AddNotesSlide(); -//Adds a paragraph into the text body. +//Adds Paragraph into the text body. IParagraph paragraph = notesSlide.NotesTextBody.AddParagraph(); -//Adds a text part into the paragraph. +//Adds text part into the Paragraph. ITextPart textPart = paragraph.AddTextPart(); textPart.Text = "The notes slide represents the contents and key notes of the corresponding slide. It is more useful when we use Presenter View while presenting the seminars through SlideShow."; //Sets Bold format for text content. -textPart.Font.Bold = true; -//Sets font style using font name. +textPart.Font.Bold=true; +// Sets font style using font name. textPart.Font.FontName = "Times New Roman"; -//Sets text content size using FontSize property. +// Sets text content size using FontSize property. textPart.Font.FontSize = 20; -//Saves the Presentation to the file system. -pptxDoc.Save("PresentationWithNotesText.pptx"); -//Closes the Presentation. -pptxDoc.Close(); +//Save the PowerPoint Presentation as stream +FileStream outputStream = new FileStream(OutputFileName, FileMode.Create); +pptxDoc.Save(outputStream); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} @@ -105,21 +99,19 @@ IPresentation pptxDoc = Presentation.Create(); ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); //Adds new notes slide in the specified slide. INotesSlide notesSlide = slide.AddNotesSlide(); -//Adds a paragraph into the text body. +//Adds Paragraph into the text body. IParagraph paragraph = notesSlide.NotesTextBody.AddParagraph(); -//Adds a text part into the paragraph. +//Adds text part into the Paragraph. ITextPart textPart = paragraph.AddTextPart(); textPart.Text = "The notes slide represents the contents and key notes of the corresponding slide. It is more useful when we use Presenter View while presenting the seminars through SlideShow."; //Sets Bold format for text content. -textPart.Font.Bold = true; -//Sets font style using font name. +textPart.Font.Bold=true; +// Sets font style using font name. textPart.Font.FontName = "Times New Roman"; -//Sets text content size using FontSize property. +// Sets text content size using FontSize property. textPart.Font.FontSize = 20; //Saves Presentation with specified file name with extension. -pptxDoc.Save("PresentationWithNotesText.pptx"); -//Closes the Presentation. -pptxDoc.Close(); +pptxDoc.Save("PresentationWithNotesSlide.pptx"); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} @@ -129,9 +121,9 @@ Dim pptxDoc As IPresentation = Presentation.Create() Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank) 'Adds new notes slide in the specified slide. Dim notesSlide As INotesSlide = slide.AddNotesSlide() -'Adds a paragraph into the text body. +'Adds Paragraph into the text body. Dim paragraph As IParagraph = notesSlide.NotesTextBody.AddParagraph() -'Adds a text part into the paragraph. +'Adds text part into the Paragraph. Dim textPart As ITextPart = paragraph.AddTextPart() textPart.Text = "The notes slide represents the contents and key notes of the corresponding slide. It is more useful when we use Presenter View while presenting the seminars through SlideShow." 'Sets Bold format for text content. @@ -141,9 +133,7 @@ textPart.Font.FontName = "Times New Roman" 'Sets text content size using FontSize property. textPart.Font.FontSize = 20 'Saves Presentation with specified file name with extension. -pptxDoc.Save("PresentationWithNotesText.pptx") -'Closes the Presentation. -pptxDoc.Close() +pptxDoc.Save("PresentationWithNotesSlide.pptx") {% endhighlight %} {% endtabs %} @@ -203,7 +193,8 @@ paragraph.FirstLineIndent = -20; // Sets the bullet character size. Here, 100 means 100% of its text. Possible values can range from 25 to 400. paragraph.ListFormat.Size = 100; //Save the PowerPoint Presentation as stream -pptxDoc.Save(OutputFileName); +FileStream outputStream = new FileStream(OutputFileName, FileMode.Create); +pptxDoc.Save(outputStream); //Closes the Presentation pptxDoc.Close(); {% endhighlight %} @@ -314,53 +305,48 @@ pptxDoc.Close() You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Create-numbered-list-in-notes-slide). - ## Removing Notes from a Slide -The following code example demonstrates how to remove the notes slide from a PowerPoint slide. +The below code example demonstrates how to remove a Notes from a PowerPoint Slide. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PowerPoint-Examples/master/Notes/Remove-notes-from-slide/.NET/Remove-notes-from-slide/Program.cs" %} -//Opens an existing PowerPoint presentation. -IPresentation pptxDoc = Presentation.Open("Sample.pptx"); -//Gets the instance of the first slide from the presentation. +//Loads or open an PowerPoint Presentation +FileStream inputStream = new FileStream(inputFileName,FileMode.Open); +IPresentation pptxDoc = Presentation.Open(inputStream); +//Gets instance of the first slide from the Presentation. ISlide slide = pptxDoc.Slides[0] as ISlide; -//Removes the notes slide from the corresponding slide. +//Removes Notes Slide from a corresponding slide. slide.RemoveNotesSlide(); -//Saves the Presentation to the file system. -pptxDoc.Save("PresentationWithNotesSlide.pptx"); -//Closes the Presentation. -pptxDoc.Close(); +//Save the PowerPoint Presentation as stream +FileStream outputStream = new FileStream(OutputFileName, FileMode.Create); +pptxDoc.Save(outputStream); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} //Opens an existing PowerPoint presentation. IPresentation pptxDoc = Presentation.Open("Sample.pptx"); -//Gets the instance of the first slide from the presentation. +//Gets instance of the first slide from the Presentation. ISlide slide = pptxDoc.Slides[0] as ISlide; -//Removes the notes slide from the corresponding slide. +//Removes Notes Slide from a corresponding slide. slide.RemoveNotesSlide(); -//Saves the Presentation with the specified file name and extension. +//Saves Presentation with specified file name with extension. pptxDoc.Save("PresentationWithNotesSlide.pptx"); -//Closes the Presentation. -pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} 'Opens an existing PowerPoint presentation. Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx") -'Gets the instance of the first slide from the presentation. +'Gets instance of the first slide from the Presentation. Dim slide As ISlide = TryCast(pptxDoc.Slides(0), ISlide) -'Removes the notes slide from the corresponding slide. +'Removes Notes Slide from a corresponding slide. slide.RemoveNotesSlide() -'Saves the Presentation with the specified file name and extension. +'Saves Presentation with specified file name with extension. pptxDoc.Save("PresentationWithNotesSlide.pptx") -'Closes the Presentation. -pptxDoc.Close() {% endhighlight %} {% endtabs %} -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Remove-notes-from-slide). \ No newline at end of file +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Remove-notes-from-slide). From a435118bb0061d3ecc30ab6d336ff11a5ca8018b Mon Sep 17 00:00:00 2001 From: Viswajith-SF4658 Date: Fri, 31 Jul 2026 17:51:40 +0530 Subject: [PATCH 4/4] Committed the existing files for UG changes --- .../NET/Working-with-NotesSlide.md | 115 ++++--- .../NET/Working-with-paragraphs.md | 307 +++++++++--------- ...aster-slide-and-layout-slide-in-c-sharp.md | 199 ++++++------ 3 files changed, 326 insertions(+), 295 deletions(-) diff --git a/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md b/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md index 2da0c9d783..a09fde3466 100644 --- a/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md +++ b/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-NotesSlide.md @@ -9,11 +9,15 @@ keywords: Working with Notes # Working with PowerPoint Notes -Notes are the contents associated with each slide and are visible only to the presenter when monitors are shared in “Presenter View”. It shows hint for the speaker, so it is often called as “Speaker Notes”. The presenter can optionally add key points to notes. You can add and modify the notes in your slide using Essential® Presentation library. +Notes are the contents associated with each slide and are visible only to the presenter when monitors are shared in “Presenter View”. They show hints for the speaker, so they are often called “Speaker Notes”. The presenter can optionally add key points to notes. You can add and modify the notes in your slide using Syncfusion® Presentation library. -## Adding Notes to a Slides +## Prerequisites -The below code example demonstrates how to create a Notes in a PowerPoint Slide. +Before you begin, make sure the following NuGet package is installed in your application. For more information on the assemblies and NuGet packages required for your target platform, refer to [Assemblies Required](Assemblies-Required) and [NuGet Packages Required](NuGet-Packages-Required). + +## Adding Notes to a Slide + +The following code example demonstrates how to add notes to a PowerPoint slide. {% tabs %} @@ -27,9 +31,10 @@ ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); INotesSlide notesSlide = slide.AddNotesSlide(); //Adds text content into the Notes Slide. notesSlide.NotesTextBody.AddParagraph("Notes content"); -//Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream(OutputFileName, FileMode.Create); -pptxDoc.Save(outputStream); +//Saves the Presentation to the file system. +pptxDoc.Save("PresentationWithNotesSlide.pptx"); +//Closes the Presentation. +pptxDoc.Close(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} @@ -43,6 +48,8 @@ INotesSlide notesSlide = slide.AddNotesSlide(); notesSlide.NotesTextBody.AddParagraph("Notes content"); //Saves Presentation with specified file name with extension. pptxDoc.Save("PresentationWithNotesSlide.pptx"); +//Closes the Presentation. +pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} @@ -56,15 +63,19 @@ Dim notesSlide As INotesSlide = slide.AddNotesSlide() notesSlide.NotesTextBody.AddParagraph("Notes content") 'Saves Presentation with specified file name with extension. pptxDoc.Save("PresentationWithNotesSlide.pptx") +'Closes the Presentation. +pptxDoc.Close() {% endhighlight %} {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Add-notes-to-PowerPoint-slide). -## Adding Text into the Notes +N> `AddNotesSlide()` returns the newly created `INotesSlide` for the specified slide. If a notes slide already exists for that slide, the existing notes slide is returned. The notes slide can also be accessed through the `slide.NotesSlide` property. -The following code example demonstrates how to add a text in a Notes. +## Adding Text into the Notes + +The following code example demonstrates how to add formatted text to notes. {% tabs %} @@ -76,20 +87,21 @@ IPresentation pptxDoc = Presentation.Create(); ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); //Adds new notes slide in the specified slide. INotesSlide notesSlide = slide.AddNotesSlide(); -//Adds Paragraph into the text body. +//Adds a paragraph into the text body. IParagraph paragraph = notesSlide.NotesTextBody.AddParagraph(); -//Adds text part into the Paragraph. +//Adds a text part into the paragraph. ITextPart textPart = paragraph.AddTextPart(); textPart.Text = "The notes slide represents the contents and key notes of the corresponding slide. It is more useful when we use Presenter View while presenting the seminars through SlideShow."; //Sets Bold format for text content. -textPart.Font.Bold=true; -// Sets font style using font name. +textPart.Font.Bold = true; +//Sets font style using font name. textPart.Font.FontName = "Times New Roman"; -// Sets text content size using FontSize property. +//Sets text content size using FontSize property. textPart.Font.FontSize = 20; -//Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream(OutputFileName, FileMode.Create); -pptxDoc.Save(outputStream); +//Saves the Presentation to the file system. +pptxDoc.Save("PresentationWithNotesText.pptx"); +//Closes the Presentation. +pptxDoc.Close(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} @@ -99,19 +111,21 @@ IPresentation pptxDoc = Presentation.Create(); ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); //Adds new notes slide in the specified slide. INotesSlide notesSlide = slide.AddNotesSlide(); -//Adds Paragraph into the text body. +//Adds a paragraph into the text body. IParagraph paragraph = notesSlide.NotesTextBody.AddParagraph(); -//Adds text part into the Paragraph. +//Adds a text part into the paragraph. ITextPart textPart = paragraph.AddTextPart(); textPart.Text = "The notes slide represents the contents and key notes of the corresponding slide. It is more useful when we use Presenter View while presenting the seminars through SlideShow."; //Sets Bold format for text content. -textPart.Font.Bold=true; -// Sets font style using font name. +textPart.Font.Bold = true; +//Sets font style using font name. textPart.Font.FontName = "Times New Roman"; -// Sets text content size using FontSize property. +//Sets text content size using FontSize property. textPart.Font.FontSize = 20; //Saves Presentation with specified file name with extension. -pptxDoc.Save("PresentationWithNotesSlide.pptx"); +pptxDoc.Save("PresentationWithNotesText.pptx"); +//Closes the Presentation. +pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} @@ -121,9 +135,9 @@ Dim pptxDoc As IPresentation = Presentation.Create() Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank) 'Adds new notes slide in the specified slide. Dim notesSlide As INotesSlide = slide.AddNotesSlide() -'Adds Paragraph into the text body. +'Adds a paragraph into the text body. Dim paragraph As IParagraph = notesSlide.NotesTextBody.AddParagraph() -'Adds text part into the Paragraph. +'Adds a text part into the paragraph. Dim textPart As ITextPart = paragraph.AddTextPart() textPart.Text = "The notes slide represents the contents and key notes of the corresponding slide. It is more useful when we use Presenter View while presenting the seminars through SlideShow." 'Sets Bold format for text content. @@ -133,16 +147,20 @@ textPart.Font.FontName = "Times New Roman" 'Sets text content size using FontSize property. textPart.Font.FontSize = 20 'Saves Presentation with specified file name with extension. -pptxDoc.Save("PresentationWithNotesSlide.pptx") +pptxDoc.Save("PresentationWithNotesText.pptx") +'Closes the Presentation. +pptxDoc.Close() {% endhighlight %} {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Add-text-in-notes). -## Adding a numbered list to Notes +N> In addition to `Bold`, `FontName`, and `FontSize`, the `ITextPart.Font` property exposes formatting options such as `Italic`, `Underline`, `FontColor`, `HighlightColor`, `StrikeThrough`, `BaselineAlignment`, and `FontScript`. For the full list of members, refer to the [ITextPart API reference](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextPart.html). -The following code example demonstrates how to create simple numbered list as Notes. +## Adding a Numbered List to Notes + +The following code example demonstrates how to create a simple numbered list as notes. {% tabs %} @@ -193,8 +211,7 @@ paragraph.FirstLineIndent = -20; // Sets the bullet character size. Here, 100 means 100% of its text. Possible values can range from 25 to 400. paragraph.ListFormat.Size = 100; //Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream(OutputFileName, FileMode.Create); -pptxDoc.Save(outputStream); +pptxDoc.Save(OutputFileName); //Closes the Presentation pptxDoc.Close(); {% endhighlight %} @@ -305,48 +322,58 @@ pptxDoc.Close() You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Create-numbered-list-in-notes-slide). + ## Removing Notes from a Slide -The below code example demonstrates how to remove a Notes from a PowerPoint Slide. +The following code example demonstrates how to remove the notes slide from a PowerPoint slide. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PowerPoint-Examples/master/Notes/Remove-notes-from-slide/.NET/Remove-notes-from-slide/Program.cs" %} -//Loads or open an PowerPoint Presentation -FileStream inputStream = new FileStream(inputFileName,FileMode.Open); -IPresentation pptxDoc = Presentation.Open(inputStream); -//Gets instance of the first slide from the Presentation. +//Opens an existing PowerPoint presentation. +IPresentation pptxDoc = Presentation.Open("Sample.pptx"); +//Gets the instance of the first slide from the presentation. ISlide slide = pptxDoc.Slides[0] as ISlide; -//Removes Notes Slide from a corresponding slide. +//Removes the notes slide from the corresponding slide. slide.RemoveNotesSlide(); -//Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream(OutputFileName, FileMode.Create); -pptxDoc.Save(outputStream); +//Saves the Presentation to the file system. +pptxDoc.Save("PresentationWithNotesSlide.pptx"); +//Closes the Presentation. +pptxDoc.Close(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} //Opens an existing PowerPoint presentation. IPresentation pptxDoc = Presentation.Open("Sample.pptx"); -//Gets instance of the first slide from the Presentation. +//Gets the instance of the first slide from the presentation. ISlide slide = pptxDoc.Slides[0] as ISlide; -//Removes Notes Slide from a corresponding slide. +//Removes the notes slide from the corresponding slide. slide.RemoveNotesSlide(); -//Saves Presentation with specified file name with extension. +//Saves the Presentation with the specified file name and extension. pptxDoc.Save("PresentationWithNotesSlide.pptx"); +//Closes the Presentation. +pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} 'Opens an existing PowerPoint presentation. Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx") -'Gets instance of the first slide from the Presentation. +'Gets the instance of the first slide from the presentation. Dim slide As ISlide = TryCast(pptxDoc.Slides(0), ISlide) -'Removes Notes Slide from a corresponding slide. +'Removes the notes slide from the corresponding slide. slide.RemoveNotesSlide() -'Saves Presentation with specified file name with extension. +'Saves the Presentation with the specified file name and extension. pptxDoc.Save("PresentationWithNotesSlide.pptx") +'Closes the Presentation. +pptxDoc.Close() {% endhighlight %} {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Notes/Remove-notes-from-slide). + +## See Also + +- [Working with Comments](Comments) +- [Working with Paragraphs](./Working-with-paragraphs) \ No newline at end of file diff --git a/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-paragraphs.md b/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-paragraphs.md index 7cf92e28ac..38c3369742 100644 --- a/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-paragraphs.md +++ b/Document-Processing/PowerPoint/PowerPoint-Library/NET/Working-with-paragraphs.md @@ -1,11 +1,11 @@ --- -title: Working with Paragraph in PowerPoint Presentation | Syncfusion -description: This section illustrates how to work with Paragraphs and texts in .NET PowerPoint Presentation +title: Working with Paragraphs in PowerPoint Presentation | Syncfusion +description: This section illustrates how to work with paragraphs and text in .NET PowerPoint Presentation. platform: document-processing control: Presentation documentation: UG --- -# Working with Paragraph +# Working with Paragraphs ## Adding Paragraph to slide @@ -17,33 +17,32 @@ The following code example demonstrates how to add a paragraph in a slide. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PowerPoint-Examples/master/Paragraphs/Add-paragraph-to-PowerPoint-slide/.NET/Add-paragraph-to-PowerPoint-slide/Program.cs" %} -//Creates PowerPoint Presentation +//Creates a PowerPoint Presentation IPresentation pptxDoc = Presentation.Create(); -//Adds slide to the PowerPoint +//Adds a slide to the PowerPoint ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); -//Adds textbox to the slide +//Adds a textbox to the slide IShape textboxShape = slide.AddTextBox(0, 0, 500, 500); -//Adds paragraph to the textbody of textbox +//Adds a paragraph to the textbody of the textbox IParagraph paragraph = textboxShape.TextBody.AddParagraph(); //Adds a TextPart to the paragraph ITextPart textPart = paragraph.AddTextPart(); //Adds text to the TextPart textPart.Text = "AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base."; -//Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream("Output.pptx", FileMode.Create); -pptxDoc.Save(outputStream); +//Saves the PowerPoint Presentation to a file +pptxDoc.Save("Output.pptx"); //Closes the Presentation pptxDoc.Close(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -//Creates PowerPoint Presentation +//Creates a PowerPoint Presentation IPresentation pptxDoc = Presentation.Create(); -//Adds slide to the PowerPoint +//Adds a slide to the PowerPoint ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); -//Adds textbox to the slide +//Adds a textbox to the slide IShape textboxShape = slide.AddTextBox(0, 0, 500, 500); -//Adds paragraph to the textbody of textbox +//Adds a paragraph to the textbody of the textbox IParagraph paragraph = textboxShape.TextBody.AddParagraph(); //Adds a TextPart to the paragraph ITextPart textPart = paragraph.AddTextPart(); @@ -56,13 +55,13 @@ pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Creates PowerPoint Presentation +'Creates a PowerPoint Presentation Dim pptxDoc As IPresentation = Presentation.Create() -'Adds slide to the PowerPoint +'Adds a slide to the PowerPoint Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank) -'Adds textbox to the slide +'Adds a textbox to the slide Dim textboxShape As IShape = slide.AddTextBox(0, 0, 500, 500) -'Adds paragraph to the textbody of textbox +'Adds a paragraph to the textbody of the textbox Dim paragraph As IParagraph = textboxShape.TextBody.AddParagraph() 'Adds a TextPart to the paragraph Dim textPart As ITextPart = paragraph.AddTextPart() @@ -78,34 +77,32 @@ pptxDoc.Close() You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Paragraphs/Add-paragraph-to-PowerPoint-slide). -## Applying Paragraph formatting +## Applying Paragraph Formatting -Each paragraph in a slide can have its own formatting types such as alignment, indent etc. The following code example demonstrates how to format a paragraph in PowerPoint presentation. +Each paragraph in a slide can have its own formatting types such as alignment, indent, and so on. The following code example demonstrates how to format a paragraph in a PowerPoint presentation. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PowerPoint-Examples/master/Paragraphs/Apply-paragraph-formatting/.NET/Apply-paragraph-formatting/Program.cs" %} -//Loads or open an PowerPoint Presentation -FileStream inputStream = new FileStream("Sample.pptx",FileMode.Open); -IPresentation pptxDoc = Presentation.Open(inputStream); -//Gets the slide from Presentation +//Loads or opens a PowerPoint Presentation +IPresentation pptxDoc = Presentation.Open("Sample.pptx"); +//Gets the slide from the Presentation ISlide slide = pptxDoc.Slides[0]; -//Gets the shape in slide -IShape textboxShape = slide.Shapes[0] as IShape; -//Gets instance of a paragraph in a textbox +//Gets the shape in the slide +IShape textboxShape = slide.Shapes[0] as IShape; +//Gets the instance of a paragraph in the textbox IParagraph paragraph = textboxShape.TextBody.Paragraphs[0]; //Applies the first line indent of the paragraph paragraph.FirstLineIndent = 10; -//Applies the horizontal alignment of the paragraph to center. +//Applies the horizontal alignment of the paragraph paragraph.HorizontalAlignment = HorizontalAlignmentType.Left; //Applies the left indent of the paragraph paragraph.LeftIndent = 8; -//Modify the end paragraph font name +//Modifies the end paragraph font name paragraph.EndParagraphFont.FontName = "Times New Roman"; -//Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream("Output.pptx", FileMode.Create); -pptxDoc.Save(outputStream); +//Saves the PowerPoint Presentation to a file +pptxDoc.Save("Output.pptx"); //Closes the Presentation pptxDoc.Close(); {% endhighlight %} @@ -113,19 +110,19 @@ pptxDoc.Close(); {% highlight c# tabtitle="C# [Windows-specific]" %} //Loads the PowerPoint Presentation IPresentation pptxDoc = Presentation.Open("Sample.pptx"); -//Gets the slide from Presentation +//Gets the slide from the Presentation ISlide slide = pptxDoc.Slides[0]; -//Gets the shape in slide -IShape textboxShape = slide.Shapes[0] as IShape; -//Gets instance of a paragraph in a textbox +//Gets the shape in the slide +IShape textboxShape = slide.Shapes[0] as IShape; +//Gets the instance of a paragraph in the textbox IParagraph paragraph = textboxShape.TextBody.Paragraphs[0]; //Applies the first line indent of the paragraph paragraph.FirstLineIndent = 10; -//Applies the horizontal alignment of the paragraph to center. +//Applies the horizontal alignment of the paragraph paragraph.HorizontalAlignment = HorizontalAlignmentType.Left; //Applies the left indent of the paragraph paragraph.LeftIndent = 8; -//Modify the end paragraph font name +//Modifies the end paragraph font name paragraph.EndParagraphFont.FontName = "Times New Roman"; //Saves the Presentation pptxDoc.Save("Output.pptx"); @@ -136,15 +133,15 @@ pptxDoc.Close(); {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} 'Loads the PowerPoint Presentation Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx") -'Gets the slide from Presentation +'Gets the slide from the Presentation Dim slide As ISlide = pptxDoc.Slides(0) -'Gets the shape in slide +'Gets the shape in the slide Dim textboxShape As IShape = TryCast(slide.Shapes(0), IShape) -'Gets instance of a paragraph in a textbox +'Gets the instance of a paragraph in the textbox Dim paragraph As IParagraph = textboxShape.TextBody.Paragraphs(0) 'Applies the first line indent of the paragraph paragraph.FirstLineIndent = 10 -'Applies the horizontal alignment of the paragraph to center. +'Applies the horizontal alignment of the paragraph paragraph.HorizontalAlignment = HorizontalAlignmentType.Left 'Applies the left indent of the paragraph paragraph.LeftIndent = 8 @@ -158,9 +155,9 @@ pptxDoc.Close() You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Paragraphs/Apply-paragraph-formatting). -## Working with text +## Working with Text -With Essential® Presentation, you can add or modify the text in a Presentation. Within the paragraph, textual contents are grouped into one or more child elements as [TextParts](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextParts.html). Each [TextPart](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextPart.html) represents a region of text with a common set of formatted text. The following code example demonstrates how to add text with different formatting into a single paragraph. +With Essential® Presentation, you can add or modify text in a Presentation. Within the paragraph, textual contents are grouped into one or more child elements as [TextParts](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextParts.html). Each [TextPart](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextPart.html) represents a region of text with a common set of formatted text. The following code example demonstrates how to add text with different formatting into a single paragraph. {% tabs %} @@ -168,11 +165,11 @@ With Essential® Presentation, you can add or modify the text in a playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PowerPoint-Examples/master/Paragraphs/Add-text-with-different-formattings/.NET/Add-text-with-different-formattings/Program.cs" %} //Creates the PowerPoint Presentation instance IPresentation pptxDoc = Presentation.Create(); -//Adds new slide to the presentation +//Adds a new slide to the Presentation ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); -//Adds textbox to the slide +//Adds a textbox to the slide IShape textboxShape2 = slide.AddTextBox(500, 0, 400, 500); -//Adds paragraph to the textbody of textbox +//Adds a paragraph to the textbody of the textbox IParagraph paragraph2 = textboxShape2.TextBody.AddParagraph(); //Adds a TextPart to the paragraph ITextPart textPartFormatting = paragraph2.AddTextPart(); @@ -196,9 +193,8 @@ IFont font2 = textPartFormatting2.Font; font2.Color = ColorObject.BlanchedAlmond; //Sets the underline type font2.Underline = TextUnderlineType.WavyDouble; -//Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream("Sample.pptx", FileMode.Create); -pptxDoc.Save(outputStream); +//Saves the PowerPoint Presentation to a file +pptxDoc.Save("Output.pptx"); //Closes the Presentation pptxDoc.Close(); {% endhighlight %} @@ -206,11 +202,11 @@ pptxDoc.Close(); {% highlight c# tabtitle="C# [Windows-specific]" %} //Creates the PowerPoint Presentation instance IPresentation pptxDoc = Presentation.Create(); -//Gets the slide from Presentation +//Adds a slide to the Presentation ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); -//Adds textbox to the slide +//Adds a textbox to the slide IShape textboxShape2 = slide.AddTextBox(500, 0, 400, 500); -//Adds paragraph to the textbody of textbox +//Adds a paragraph to the textbody of the textbox IParagraph paragraph2 = textboxShape2.TextBody.AddParagraph(); //Adds a TextPart to the paragraph ITextPart textPartFormatting = paragraph2.AddTextPart(); @@ -241,13 +237,13 @@ pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Loads the PowerPoint Presentation +'Creates the PowerPoint Presentation instance Dim pptxDoc As IPresentation = Presentation.Create() -'Gets the slide from Presentation +'Adds a slide to the Presentation Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank) -'Adds textbox to the slide +'Adds a textbox to the slide Dim textboxShape2 As IShape = slide.AddTextBox(500, 0, 400, 500) -'Adds paragraph to the textbody of textbox +'Adds a paragraph to the textbody of the textbox Dim paragraph2 As IParagraph = textboxShape2.TextBody.AddParagraph() 'Adds a TextPart to the paragraph Dim textPartFormatting As ITextPart = paragraph2.AddTextPart() @@ -281,69 +277,67 @@ pptxDoc.Close() You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Paragraphs/Add-text-with-different-formattings). -## Modifying text +## Modifying Text -You can modify a text by accessing the existing paragraphs in a Presentation. The following code example demonstrates how to modify the content in a paragraph. +You can modify text by accessing the existing paragraphs in a Presentation. The following code example demonstrates how to modify the content in a paragraph. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PowerPoint-Examples/master/Paragraphs/Modify-existing-text/.NET/Modify-existing-text/Program.cs" %} -//Loads or open an PowerPoint Presentation -FileStream inputStream = new FileStream("Sample.pptx",FileMode.Open); -IPresentation pptxDoc = Presentation.Open(inputStream); -//Retrieves the first slide from Presentation +//Loads or opens a PowerPoint Presentation that contains a shape with a text body +IPresentation pptxDoc = Presentation.Open("Sample.pptx"); +//Retrieves the first slide from the Presentation ISlide slide = pptxDoc.Slides[0]; -//Retrieves the first shape. +//Retrieves the first shape IShape shape = slide.Shapes[0] as IShape; -//Retrieves the first paragraph of the shape. +//Retrieves the first paragraph of the shape IParagraph paragraph = shape.TextBody.Paragraphs[0]; -//Retrieves the first TextPart of the shape. +//Retrieves the first TextPart of the shape ITextPart textPart = paragraph.TextParts[0]; -//Modifies the text content of the TextPart. +//Modifies the text content of the TextPart textPart.Text = "Hello Presentation"; -//Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream("Output.pptx", FileMode.Create); -pptxDoc.Save(outputStream); -//Closes the Presentation. +//Saves the PowerPoint Presentation to a file +pptxDoc.Save("Output.pptx"); +//Closes the Presentation pptxDoc.Close(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -//Opens an existing Presentation from file system. +//Opens an existing Presentation from the file system IPresentation pptxDoc = Presentation.Open("Sample.pptx"); -//Retrieves the first slide from Presentation +//Retrieves the first slide from the Presentation ISlide slide = pptxDoc.Slides[0]; -//Retrieves the first shape. +//Retrieves the first shape IShape shape = slide.Shapes[0] as IShape; -//Retrieves the first paragraph of the shape. +//Retrieves the first paragraph of the shape IParagraph paragraph = shape.TextBody.Paragraphs[0]; -//Retrieves the first TextPart of the shape. +//Retrieves the first TextPart of the shape ITextPart textPart = paragraph.TextParts[0]; -//Modifies the text content of the TextPart. +//Modifies the text content of the TextPart textPart.Text = "Hello Presentation"; -//Saves the presentation to the file system. -pptxDoc.Save("Result.pptx"); -//Closes the Presentation. +//Saves the Presentation to the file system +pptxDoc.Save("Output.pptx"); +//Closes the Presentation pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Opens an existing Presentation from file system. +'Opens an existing Presentation from the file system Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx") -'Retrieves the first slide from Presentation +'Retrieves the first slide from the Presentation Dim slide As ISlide = pptxDoc.Slides(0) -'Retrieves the first shape. +'Retrieves the first shape Dim shape As IShape = TryCast(slide.Shapes(0), IShape) -'Retrieves the first paragraph of the shape. +'Retrieves the first paragraph of the shape Dim paragraph As IParagraph = shape.TextBody.Paragraphs(0) -'Retrieves the first TextPart of the shape. +'Retrieves the first TextPart of the shape Dim textPart As ITextPart = paragraph.TextParts(0) -'Modifies the text content of the TextPart. +'Modifies the text content of the TextPart textPart.Text = "Hello Presentation" -'Saves the presentation to the file system. -pptxDoc.Save("Result.pptx") -'Closes the Presentation. +'Saves the Presentation to the file system +pptxDoc.Save("Output.pptx") +'Closes the Presentation pptxDoc.Close() {% endhighlight %} @@ -351,122 +345,121 @@ pptxDoc.Close() You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Paragraphs/Modify-existing-text). -### Edit a language of TextPart +## Changing the Language of a TextPart -With Essential® Presentation, you can modify the language of Presentation [TextPart](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextPart.html). This allows viewer application to check spelling and grammar according to the language of each [TextPart](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextPart.html). The following code example demonstrates how to modify a language of Presentation [TextPart](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextPart.html). +With Essential® Presentation, you can modify the language of a Presentation [TextPart](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextPart.html). This allows viewer applications to check spelling and grammar according to the language of each [TextPart](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextPart.html). The following code example demonstrates how to modify the language of a Presentation [TextPart](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ITextPart.html). {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PowerPoint-Examples/master/Paragraphs/Modify-text-language/.NET/Modify-text-language/Program.cs" %} -//Create a Microsoft PowerPoint instance +//Creates a Microsoft PowerPoint instance IPresentation pptxDoc = Presentation.Create(); -//Add the slide for Presentation +//Adds a slide to the Presentation ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); -//Adds textbox to the slide +//Adds a textbox to the slide IShape textboxShape = slide.AddTextBox(500, 0, 400, 500); -//Adds paragraph to the textbody of textbox +//Adds a paragraph to the textbody of the textbox IParagraph paragraph = textboxShape.TextBody.AddParagraph(); //Adds a TextPart to the paragraph ITextPart textPart = paragraph.AddTextPart(); //Adds text to the TextPart textPart.Text = "AdventureWorks Cycles"; -//Sets a language as "Spanish (Argentina)" for TextPart. +//Sets a language as "Spanish (Argentina)" for the TextPart textPart.Font.LanguageID = (short)LocaleIDs.es_AR; -//Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream("Output.pptx", FileMode.Create); -pptxDoc.Save(outputStream); +//Saves the PowerPoint Presentation to a file +pptxDoc.Save("Output.pptx"); //Closes the Presentation pptxDoc.Close(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -//Create a Microsoft PowerPoint instance +//Creates a Microsoft PowerPoint instance IPresentation pptxDoc = Presentation.Create(); -//Add the slide for Presentation +//Adds a slide to the Presentation ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); -//Adds textbox to the slide +//Adds a textbox to the slide IShape textboxShape = slide.AddTextBox(500, 0, 400, 500); -//Adds paragraph to the textbody of textbox +//Adds a paragraph to the textbody of the textbox IParagraph paragraph = textboxShape.TextBody.AddParagraph(); //Adds a TextPart to the paragraph ITextPart textPart = paragraph.AddTextPart(); //Adds text to the TextPart textPart.Text = "AdventureWorks Cycles"; -//Sets a language as "Spanish (Argentina)" for TextPart. +//Sets a language as "Spanish (Argentina)" for the TextPart textPart.Font.LanguageID = (short)LocaleIDs.es_AR; -//Save a PowerPoint document +//Saves the PowerPoint Presentation to a file pptxDoc.Save("Output.pptx"); -//Close the PowerPoint instance -pptxDoc.Dispose(); +//Closes the Presentation +pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Create a Microsoft PowerPoint instance -Dim pptxDoc As IPresentation = Presentation.Create -'Add the slide for Presentation +'Creates a Microsoft PowerPoint instance +Dim pptxDoc As IPresentation = Presentation.Create() +'Adds a slide to the Presentation Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank) -'Adds textbox to the slide +'Adds a textbox to the slide Dim textboxShape As IShape = slide.AddTextBox(500, 0, 400, 500) -'Adds paragraph to the textbody of textbox -Dim paragraph As IParagraph = textboxShape.TextBody.AddParagraph +'Adds a paragraph to the textbody of the textbox +Dim paragraph As IParagraph = textboxShape.TextBody.AddParagraph() 'Adds a TextPart to the paragraph -Dim textPart As ITextPart = paragraph.AddTextPart +Dim textPart As ITextPart = paragraph.AddTextPart() 'Adds text to the TextPart textPart.Text = "AdventureWorks Cycles" -'Sets a language as "Spanish (Argentina)" for TextPart. +'Sets a language as "Spanish (Argentina)" for the TextPart textPart.Font.LanguageID = CType(LocaleIDs.es_AR,Short) -'Save a PowerPoint document +'Saves the PowerPoint Presentation to a file pptxDoc.Save("Output.pptx") -'Close the PowerPoint instance -pptxDoc.Dispose +'Closes the Presentation +pptxDoc.Close() {% endhighlight %} {% endtabs %} You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Paragraphs/Modify-text-language). -## Enabling shrink text on overflow option +## Enabling the Shrink Text on Overflow Option -In a PowerPoint slide, if you add a text more than a shape can hold, the text will overflow from the shape. But by using a Shrink text on overflow option, you can fit a large text within a shape. The following code example demonstrates how to enable this property. +In a PowerPoint slide, if you add more text than a shape can hold, the text overflows from the shape. By using the **Shrink text on overflow** option, you can fit large text within a shape. The following code example demonstrates how to enable this property. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} -//The Essential Presentation Library does not provides support to FitTextOption in C# [Cross-platform] platforms. +//The Essential Presentation Library does not provide support for FitTextOption in C# (Cross-platform) platforms. {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -// Create a new PowerPoint file. +//Creates a new PowerPoint file using (IPresentation ppDoc = Presentation.Create()) { - //Add a slide to the PowerPoint file. + //Adds a slide to the PowerPoint file ISlide slide = ppDoc.Slides.Add(SlideLayoutType.Blank); - //Add a text box to the slide - IShape textBox = slide.Shapes.AddTextBox(100, 100, 100, 100); - //Add text to the text box. + //Adds a textbox to the slide + IShape textBox = slide.AddTextBox(100, 100, 100, 100); + //Adds a paragraph with text to the textbox textBox.TextBody.AddParagraph("AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company."); - //Set the property to shrink text on overflow. + //Sets the property to shrink text on overflow textBox.TextBody.FitTextOption = FitTextOption.ShrinkTextOnOverFlow; - //Save the PowerPoint file - ppDoc.Save("Sample.pptx"); + //Saves the PowerPoint file + ppDoc.Save("Output.pptx"); } {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Create a new PowerPoint file +'Creates a new PowerPoint file Dim pptxDoc As IPresentation = Presentation.Create() -'Adds slide to the PowerPoint +'Adds a slide to the PowerPoint Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank) -'Adds textbox to the slide +'Adds a textbox to the slide Dim textboxShape As IShape = slide.AddTextBox(0, 0, 500, 500) -'Adds paragraph to the textbody of textbox +'Adds a paragraph with text to the textbox Dim paragraph As IParagraph = textboxShape.TextBody.AddParagraph("AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company.") -'Set the property to shrink text on overflow. +'Sets the property to shrink text on overflow textboxShape.TextBody.FitTextOption = FitTextOption.ShrinkTextOnOverFlow -'Save the PowerPoint file +'Saves the PowerPoint file pptxDoc.Save("Output.pptx") -'Close the PowerPoint file +'Closes the PowerPoint file pptxDoc.Close() {% endhighlight %} @@ -474,9 +467,9 @@ pptxDoc.Close() You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Paragraphs/Enable-text-shrink-on-overflow). -N> The shrink text on overflow is not supported in UWP, C# [Cross-platform] and Xamarin platforms. +> **Note:** The shrink text on overflow option is not supported in UWP, C# (Cross-platform), and Xamarin platforms. -## Removing the paragraph +## Removing a Paragraph The following code example demonstrates how to remove a paragraph from a slide. @@ -484,10 +477,9 @@ The following code example demonstrates how to remove a paragraph from a slide. {% highlight c# tabtitle="C# [Cross-platform]" playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/PowerPoint-Examples/master/Paragraphs/Remove-paragraph/.NET/Remove-paragraph/Program.cs" %} -//Loads or open an PowerPoint Presentation -FileStream inputStream = new FileStream("Sample.pptx",FileMode.Open); -IPresentation pptxDoc = Presentation.Open(inputStream); -//Retrieves the first slide from Presentation +//Loads or opens a PowerPoint Presentation that contains a shape with at least one paragraph +IPresentation pptxDoc = Presentation.Open("Sample.pptx"); +//Retrieves the first slide from the Presentation ISlide slide = pptxDoc.Slides[0]; //Retrieves the first shape IShape shape = slide.Shapes[0] as IShape; @@ -495,17 +487,16 @@ IShape shape = slide.Shapes[0] as IShape; IParagraph paragraph = shape.TextBody.Paragraphs[0]; //Removes the first paragraph from the textbody of the shape shape.TextBody.Paragraphs.Remove(paragraph); -//Save the PowerPoint Presentation as stream -FileStream outputStream = new FileStream("Output.pptx", FileMode.Create); -pptxDoc.Save(outputStream); +//Saves the PowerPoint Presentation to a file +pptxDoc.Save("Output.pptx"); //Closes the Presentation pptxDoc.Close(); {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -//Opens an existing Presentation from file system. +//Opens an existing Presentation from the file system IPresentation pptxDoc = Presentation.Open("Sample.pptx"); -//Retrieves the first slide from Presentation +//Retrieves the first slide from the Presentation ISlide slide = pptxDoc.Slides[0]; //Retrieves the first shape IShape shape = slide.Shapes[0] as IShape; @@ -513,26 +504,26 @@ IShape shape = slide.Shapes[0] as IShape; IParagraph paragraph = shape.TextBody.Paragraphs[0]; //Removes the first paragraph from the textbody of the shape shape.TextBody.Paragraphs.Remove(paragraph); -//Saves the presentation to the file system -pptxDoc.Save("Result.pptx"); +//Saves the Presentation to the file system +pptxDoc.Save("Output.pptx"); //Closes the Presentation pptxDoc.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Opens an existing Presentation from file system. +'Opens an existing Presentation from the file system Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx") -'Retrieves the first slide from Presentation +'Retrieves the first slide from the Presentation Dim slide As ISlide = pptxDoc.Slides(0) -'Retrieves the first shape. +'Retrieves the first shape Dim shape As IShape = TryCast(slide.Shapes(0), IShape) -'Retrieves the first paragraph of the shape. +'Retrieves the first paragraph of the shape Dim paragraph As IParagraph = shape.TextBody.Paragraphs(0) -'Removes the first paragraph from the textbody of the shape. +'Removes the first paragraph from the textbody of the shape shape.TextBody.Paragraphs.Remove(paragraph) -'Saves the presentation to the file system. -pptxDoc.Save("Result.pptx") -'Closes the Presentation. +'Saves the Presentation to the file system +pptxDoc.Save("Output.pptx") +'Closes the Presentation pptxDoc.Close() {% endhighlight %} @@ -542,4 +533,4 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## See Also -* [How to change all font names in PowerPoint using C#?](https://support.syncfusion.com/kb/article/16089/how-to-change-all-font-names-in-powerpoint-using-c) \ No newline at end of file +* [How to change all font names in PowerPoint using C#](https://support.syncfusion.com/kb/article/16089/how-to-change-all-font-names-in-powerpoint-using-c) \ No newline at end of file diff --git a/Document-Processing/PowerPoint/PowerPoint-Library/NET/create-read-edit-master-slide-and-layout-slide-in-c-sharp.md b/Document-Processing/PowerPoint/PowerPoint-Library/NET/create-read-edit-master-slide-and-layout-slide-in-c-sharp.md index d646362f74..376c4fc60d 100644 --- a/Document-Processing/PowerPoint/PowerPoint-Library/NET/create-read-edit-master-slide-and-layout-slide-in-c-sharp.md +++ b/Document-Processing/PowerPoint/PowerPoint-Library/NET/create-read-edit-master-slide-and-layout-slide-in-c-sharp.md @@ -6,64 +6,62 @@ control: PowerPoint documentation: UG --- -# Create and edit Master and Layout slides +# Create, Read, and Edit Master and Layout slides -To get all the slides in same format, you should perform those changes in the Slide Master or Layout Master. The changes will be applied to all the slides, which inherits the master slide or layout slide. +To make all slides share the same format, apply your changes to the Slide Master or Layout Master. The changes are applied to every slide that inherits the master slide or layout slide. The [Syncfusion PowerPoint library](https://www.syncfusion.com/powerpoint-framework/net) supports the following: -1. Access the [MasterSlide](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.IMasterSlide.html) in PowerPoint file. -2. Add [LayoutSlide](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ILayoutSlide.html) to the [MasterSlide](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.IMasterSlide.html). +1. Access the [MasterSlide](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.IMasterSlide.html) in a PowerPoint presentation. +2. Add a [LayoutSlide](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ILayoutSlide.html) to the [MasterSlide](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.IMasterSlide.html). 3. Customize the [LayoutSlide](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.ILayoutSlide.html). -4. Create a slide with 9 pre-defined layout slides. +4. Add a slide with one of the pre-defined layout slides. 5. Customize the layout slides to fit your own scenarios. ## Access the MasterSlide -In PowerPoint presentation, the [MasterSlide](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.IMasterSlide.html) is the top slide that controls all information about the theme, layout, background, color, fonts, and positioning of all slides. Using this MasterSlide, you can easily adjust the look of an existing theme or make overall changes to all your slides. +In a PowerPoint presentation, the [MasterSlide](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.IMasterSlide.html) is the top slide that controls all information about the theme, layout, background, color, fonts, and positioning of all slides. Using this MasterSlide, you can easily adjust the look of an existing theme or make overall changes to all your slides. -The following code example demonstrates how to access the [MasterSlide](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.IMasterSlide.html) in a PowerPoint presentation. +The following code example demonstrates how to access the [MasterSlide](https://help.syncfusion.com/cr/document-processing/Syncfusion.Presentation.IMasterSlide.html) in a PowerPoint presentation. The `ShapeName` property returns the name of the shape as a string and is used here only for demonstration. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} //Create a PowerPoint presentation -IPresentation pptxDoc = Presentation.Create(); -//Access the first master slide in PowerPoint file -IMasterSlide masterSlide = pptxDoc.Masters[0]; -//Get the first shape name from the master slide -string shapeName = masterSlide.Shapes[0].ShapeName; -//Save the PowerPoint Presentation to MemoryStream. -MemoryStream outputStream = new MemoryStream(); -pptxDoc.Save(outputStream); -//Close the Presentation instance -pptxDoc.Close(); +using (IPresentation pptxDoc = Presentation.Create()) +{ + //Access the first master slide in the PowerPoint presentation + IMasterSlide masterSlide = pptxDoc.Masters[0]; + //Get the first shape name from the master slide + string shapeName = masterSlide.Shapes[0].ShapeName; + //Save the PowerPoint presentation to a file + pptxDoc.Save("Sample.pptx"); +} {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} //Create a PowerPoint presentation -IPresentation pptxDoc = Presentation.Create(); -//Access the first master slide in PowerPoint file -IMasterSlide masterSlide = pptxDoc.Masters[0]; -//Get the first shape name from the master slide -string shapeName = masterSlide.Shapes[0].ShapeName; -//Save the PowerPoint file -pptxDoc.Save("Sample.pptx"); -//Close the Presentation instance -pptxDoc.Close(); +using (IPresentation pptxDoc = Presentation.Create()) +{ + //Access the first master slide in the PowerPoint presentation + IMasterSlide masterSlide = pptxDoc.Masters[0]; + //Get the first shape name from the master slide + string shapeName = masterSlide.Shapes[0].ShapeName; + //Save the PowerPoint presentation to a file + pptxDoc.Save("Sample.pptx"); +} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} 'Create a PowerPoint presentation -Dim pptxDoc As IPresentation = Presentation.Create() -'Access the first master slide in PowerPoint file. -Dim masterSlide As IMasterSlide = pptxDoc.Masters(0) -'Get the first shape name from the master slide -Dim shapeName As String = masterSlide.Shapes(0).ShapeName -'Save the PowerPoint file. -pptxDoc.Save("AccessMasterSlide.pptx") -'Close the Presentation instance -pptxDoc.Close() +Using pptxDoc As IPresentation = Presentation.Create() + 'Access the first master slide in the PowerPoint presentation. + Dim masterSlide As IMasterSlide = pptxDoc.Masters(0) + 'Get the first shape name from the master slide + Dim shapeName As String = masterSlide.Shapes(0).ShapeName + 'Save the PowerPoint presentation to a file. + pptxDoc.Save("AccessMasterSlide.pptx") +End Using {% endhighlight %} {% endtabs %} @@ -72,7 +70,7 @@ You can download a complete working sample from [GitHub](https://github.com/Sync ## Change background of Master slide -You can change the background of the master slide, all slides in the presentation would receive the same background settings. The following code example demonstrates how to set the background for a master slide. +You can change the background of the master slide, and all slides in the presentation will receive the same background settings. The following code example demonstrates how to set a solid background for a master slide. The `FillType` enumeration also supports `Gradient`, `Pattern`, and `Picture` fills; refer to the API reference for the full list. {% tabs %} @@ -81,19 +79,20 @@ playgroundButtonLink="https://raw.githubusercontent.com/SyncfusionExamples/Power //Create a PowerPoint presentation. using (IPresentation pptxDoc = Presentation.Create()) { - //Access the first master slide in PowerPoint file. + //Access the first master slide in the PowerPoint presentation. IMasterSlide masterSlide = pptxDoc.Masters[0]; //Retrieve the background instance. IBackground background = masterSlide.Background; - //Set the fill type for background as Solid fill. + //Set the fill type for the background as Solid fill. background.Fill.FillType = FillType.Solid; - //Get the instance for solid Fill. + //Get the instance for the solid fill. ISolidFill solidFill = background.Fill.SolidFill; - //Set the color for solid fill object. + //Set the color for the solid fill object. solidFill.Color = ColorObject.Green; - //Save the PowerPoint Presentation to MemoryStream. - MemoryStream outputStream = new MemoryStream(); - pptxDoc.Save(outputStream); + //Add a slide so the master background is applied. + pptxDoc.Slides.Add(masterSlide.LayoutSlides[0]); + //Save the PowerPoint presentation to a file. + pptxDoc.Save("Sample.pptx"); } {% endhighlight %} @@ -101,17 +100,19 @@ using (IPresentation pptxDoc = Presentation.Create()) //Create a PowerPoint presentation. using (IPresentation pptxDoc = Presentation.Create()) { - //Access the first master slide in PowerPoint file. + //Access the first master slide in the PowerPoint presentation. IMasterSlide masterSlide = pptxDoc.Masters[0]; //Retrieve the background instance. IBackground background = masterSlide.Background; - //Set the fill type for background as Solid fill. + //Set the fill type for the background as Solid fill. background.Fill.FillType = FillType.Solid; - //Get the instance for solid Fill. + //Get the instance for the solid fill. ISolidFill solidFill = background.Fill.SolidFill; - //Set the color for solid fill object. + //Set the color for the solid fill object. solidFill.Color = ColorObject.Green; - //Save the PowerPoint file. + //Add a slide so the master background is applied. + pptxDoc.Slides.Add(masterSlide.LayoutSlides[0]); + //Save the PowerPoint presentation to a file. pptxDoc.Save("Sample.pptx"); } {% endhighlight %} @@ -119,17 +120,19 @@ using (IPresentation pptxDoc = Presentation.Create()) {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} 'Create a PowerPoint presentation. Using pptxDoc As IPresentation = Presentation.Create() - 'Access the first master slide in PowerPoint file. + 'Access the first master slide in the PowerPoint presentation. Dim masterSlide As IMasterSlide = pptxDoc.Masters(0) 'Retrieve the background instance. Dim background As IBackground = masterSlide.Background - 'Set the fill type for background as Solid fill. + 'Set the fill type for the background as Solid fill. background.Fill.FillType = FillType.Solid - 'Get the instance for solid Fill. + 'Get the instance for the solid fill. Dim solidFill As ISolidFill = background.Fill.SolidFill - 'Set the color for solid fill object. + 'Set the color for the solid fill object. solidFill.Color = ColorObject.Green - 'Save the PowerPoint file. + 'Add a slide so the master background is applied. + pptxDoc.Slides.Add(masterSlide.LayoutSlides(0)) + 'Save the PowerPoint presentation to a file. pptxDoc.Save("Sample.pptx") End Using {% endhighlight %} @@ -138,60 +141,70 @@ End Using You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Master-and-Layout-slides/Modify-PowerPoint-master-slide-background). -## Create a custom LayoutSlide +## Create a Custom Layout Slide -The real-world scenarios always require more predefined templates. The [.NET PowerPoint Library](https://www.syncfusion.com/document-sdk/net-powerpoint-library) lets you build your own custom layout designs and use them to create individual slides. +Real-world scenarios often require additional predefined templates. The [.NET PowerPoint Library](https://www.syncfusion.com/document-sdk/net-powerpoint-library) lets you build your own custom layout designs and use them to create individual slides. -The following code example demonstrates how to create new custom layout slide and access layout slide in Presentation. +The following code example demonstrates how to create a new custom layout slide in a PowerPoint presentation. The `SlideLayoutType` enumeration includes other values such as `Title`, `TitleAndContent`, `SectionHeader`, and `TwoContent`; see the API reference for the full list. {% tabs %} {% highlight c# tabtitle="C# [Cross-platform]" %} -//Create a PowerPoint instance -IPresentation pptxDoc = Presentation.Create(); -//Add a new LayoutSlide to the PowerPoint file -ILayoutSlide layoutSlide = pptxDoc.Masters[0].LayoutSlides.Add(SlideLayoutType.Blank, "CustomLayout"); -//Add a shape to the LayoutSlide -IShape shape = layoutSlide.Shapes.AddShape(AutoShapeType.Diamond, 30, 20, 400, 300); -//Change the background color for LayoutSlide -layoutSlide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(78, 89, 90); -//Save the PowerPoint Presentation to MemoryStream. -MemoryStream outputStream = new MemoryStream(); -pptxDoc.Save(outputStream); -//Close the Presentation instance -pptxDoc.Close(); +//Create a PowerPoint presentation. +using (IPresentation pptxDoc = Presentation.Create()) +{ + //Add a new layout slide to the PowerPoint presentation. + ILayoutSlide layoutSlide = pptxDoc.Masters[0].LayoutSlides.Add(SlideLayoutType.Blank, "CustomLayout"); + //Add a shape to the layout slide. + IShape shape = layoutSlide.Shapes.AddShape(AutoShapeType.Diamond, 30, 20, 400, 300); + //Set a fill color for the added shape. + shape.Fill.SolidFill.Color = ColorObject.FromArgb(78, 89, 90); + //Change the background color for the layout slide. + layoutSlide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(78, 89, 90); + //Save the PowerPoint presentation to a file. + pptxDoc.Save("LayoutSlide.pptx"); +} {% endhighlight %} {% highlight c# tabtitle="C# [Windows-specific]" %} -//Create a PowerPoint instance -IPresentation pptxDoc = Presentation.Create(); -//Add a new LayoutSlide to the PowerPoint file -ILayoutSlide layoutSlide = pptxDoc.Masters[0].LayoutSlides.Add(SlideLayoutType.Blank, "CustomLayout"); -//Add a shape to the LayoutSlide -IShape shape = layoutSlide.Shapes.AddShape(AutoShapeType.Diamond, 30, 20, 400, 300); -//Change the background color for LayoutSlide -layoutSlide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(78, 89, 90); -//Save the PowerPoint file -pptxDoc.Save("LayoutSlide.pptx"); -//Close the Presentation instance -pptxDoc.Close(); +//Create a PowerPoint presentation. +using (IPresentation pptxDoc = Presentation.Create()) +{ + //Add a new layout slide to the PowerPoint presentation. + ILayoutSlide layoutSlide = pptxDoc.Masters[0].LayoutSlides.Add(SlideLayoutType.Blank, "CustomLayout"); + //Add a shape to the layout slide. + IShape shape = layoutSlide.Shapes.AddShape(AutoShapeType.Diamond, 30, 20, 400, 300); + //Set a fill color for the added shape. + shape.Fill.SolidFill.Color = ColorObject.FromArgb(78, 89, 90); + //Change the background color for the layout slide. + layoutSlide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(78, 89, 90); + //Save the PowerPoint presentation to a file. + pptxDoc.Save("LayoutSlide.pptx"); +} {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Creates a PowerPoint instance -Dim pptxDoc As IPresentation = Presentation.Create() -'Add a new LayoutSlide to the PowerPoint file -Dim layoutSlide As ILayoutSlide = pptxDoc.Masters(0).LayoutSlides.Add(SlideLayoutType.Blank, "CustomLayout") -'Add a shape to the LayoutSlide -Dim shape As IShape = layoutSlide.Shapes.AddShape(AutoShapeType.Diamond, 30, 20, 400, 300) -'Change the background color for LayoutSlide +'Create a PowerPoint presentation. +Using pptxDoc As IPresentation = Presentation.Create() + 'Add a new layout slide to the PowerPoint presentation. + Dim layoutSlide As ILayoutSlide = pptxDoc.Masters(0).LayoutSlides.Add(SlideLayoutType.Blank, "CustomLayout") + 'Add a shape to the layout slide. + Dim shape As IShape = layoutSlide.Shapes.AddShape(AutoShapeType.Diamond, 30, 20, 400, 300) + 'Set a fill color for the added shape. layoutSlide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(78, 89, 90) -'Save the PowerPoint file -pptxDoc.Save("LayoutSlide.pptx") -'Close the Presentation instance -pptxDoc.Close() + 'Change the background color for the layout slide. + layoutSlide.Background.Fill.SolidFill.Color = ColorObject.FromArgb(78, 89, 90) + 'Save the PowerPoint presentation to a file. + pptxDoc.Save("LayoutSlide.pptx") +End Using {% endhighlight %} {% endtabs %} -You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Master-and-Layout-slides/Create-custom-layout-slide). \ No newline at end of file +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PowerPoint-Examples/tree/master/Master-and-Layout-slides/Create-custom-layout-slide). + +## See Also + +* [Loading and Saving the Presentation](Loading-and-Saving-the-Presentation) +* [NuGet Packages Required](NuGet-Packages-Required) +* [Assemblies Required](Assemblies-Required) \ No newline at end of file