Updated January 9, 2025
Share:

Slide Element Tutorial

IronPPT is a robust PowerPoint library designed to help .NET C# developers seamlessly integrate the ability to create, read, and edit PowerPoint presentations into their applications. In the context of a PowerPoint presentation, slides are the foundational elements that structure and organize the content.

Table of Contents

Get started with IronPPT

Start using IronPPT in your project today with a free trial.

First Step:
green arrow pointer


Add Text

Text Content

Whether you're creating a new presentation or editing an existing one, text management tools give you full control over text placement and formatting, allowing you to design slides that convey your message clearly and professionally.

:path=/static-assets/ppt/content-code-examples/tutorials/slide-element-add-text.cs
using IronPPT;
using IronPPT.Models;

// Create new PowerPoint presentation
var document = new PresentationDocument();

// Add text
var text = document.Slides[0].AddText("Hello");

// Append text
text.Append(new Text(" There!"));

// Remove text
document.Slides[0].Texts[0].Remove();

// Export PowerPoint presentation
document.Save("addText.pptx");
Imports IronPPT
Imports IronPPT.Models

' Create new PowerPoint presentation
Private document = New PresentationDocument()

' Add text
Private text = document.Slides(0).AddText("Hello")

' Append text
text.Append(New Text(" There!"))

' Remove text
document.Slides(0).Texts(0).Remove()

' Export PowerPoint presentation
document.Save("addText.pptx")
VB   C#

Set Styling

Styling text enables you to customize its visual appearance by defining attributes like font size, color, style, strikethrough, and underline. Applying these styles enhances the text's presentation and improves the overall look of the document.

:path=/static-assets/ppt/content-code-examples/tutorials/slide-element-text-style.cs
using IronPPT;
using IronPPT.Models;
 
var document = new PresentationDocument();

// Customize text style
var textStyle = new TextStyle
{
    IsBold = true,
    IsItalic = true,
    Color = Color.Blue,
    Strike = StrikValue.SingleStrike,
    Outline = true,
    NoProof = true,
    Spacing = 10.0,
    Underline = new Underline { LineValue = UnderlineValues.Single, Color = Color.Red },
    Languages = "en-US",
    SpecVanish = false,
};

// Add style to text
var text = new Text("Hello World");
text.TextStyle = textStyle;

// Add text
document.Slides[0].AddText(text);

document.Save("textStyle.pptx");
Imports IronPPT
Imports IronPPT.Models

Private document = New PresentationDocument()

' Customize text style
Private textStyle = New TextStyle With {
	.IsBold = True,
	.IsItalic = True,
	.Color = Color.Blue,
	.Strike = StrikValue.SingleStrike,
	.Outline = True,
	.NoProof = True,
	.Spacing = 10.0,
	.Underline = New Underline With {
		.LineValue = UnderlineValues.Single,
		.Color = Color.Red
	},
	.Languages = "en-US",
	.SpecVanish = False
}

' Add style to text
Private text = New Text("Hello World")
text.TextStyle = textStyle

' Add text
document.Slides(0).AddText(text)

document.Save("textStyle.pptx")
VB   C#

Add Images

Adjust image settings for optimal display. Proper configuration ensures images are visually appealing and appropriately suited to their context.

:path=/static-assets/ppt/content-code-examples/tutorials/slide-element-add-image.cs
using IronPPT;
using IronPPT.Models;
 
// Create new PowerPoint presentation
var document = new PresentationDocument();
 
// Add image
Image image = new Image();
image.LoadFromFile("sample.png");
var newImage = document.AddImage(image, 0);
 
// Edit image's properties
newImage.Position = (200, 200);
newImage.Angle = 45;
newImage.Name = "new image";
newImage.Width = 150;
newImage.Height = 150;
 
// Export PowerPoint presentation
document.Save("addImage.pptx");
Imports IronPPT
Imports IronPPT.Models

' Create new PowerPoint presentation
Private document = New PresentationDocument()

' Add image
Private image As New Image()
image.LoadFromFile("sample.png")
Dim newImage = document.AddImage(image, 0)

' Edit image's properties
newImage.Position = (200, 200)
newImage.Angle = 45
newImage.Name = "new image"
newImage.Width = 150
newImage.Height = 150

' Export PowerPoint presentation
document.Save("addImage.pptx")
VB   C#

Add Shapes

Easily add and customize shapes in your presentation by defining their type, dimensions (width and height), fill and outline colors, and position on the slide.

:path=/static-assets/ppt/content-code-examples/tutorials/slide-element-add-image.cs
using IronPPT;
using IronPPT.Models;
 
// Create new PowerPoint presentation
var document = new PresentationDocument();
 
// Add image
Image image = new Image();
image.LoadFromFile("sample.png");
var newImage = document.AddImage(image, 0);
 
// Edit image's properties
newImage.Position = (200, 200);
newImage.Angle = 45;
newImage.Name = "new image";
newImage.Width = 150;
newImage.Height = 150;
 
// Export PowerPoint presentation
document.Save("addImage.pptx");
Imports IronPPT
Imports IronPPT.Models

' Create new PowerPoint presentation
Private document = New PresentationDocument()

' Add image
Private image As New Image()
image.LoadFromFile("sample.png")
Dim newImage = document.AddImage(image, 0)

' Edit image's properties
newImage.Position = (200, 200)
newImage.Angle = 45
newImage.Name = "new image"
newImage.Width = 150
newImage.Height = 150

' Export PowerPoint presentation
document.Save("addImage.pptx")
VB   C#
Chaknith Bin

Chaknith Bin

Software Engineer

Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.