# Getting Started with IronPPT
## IronPowerPoint: PowerPoint Library for .NET
**IronPPT** is a PowerPoint library developed by Iron Software. It excels in providing robust functionality for working with PowerPoint presentations in .NET applications.
- Load, manipulate, and save PowerPoint presentations. Easily work with .pptx and .ppt files.
- SlideSetup: Configure slide size, orientation, background color, and layout.
- Text: Handle text content, styles, splitting, appending text, and adding text boxes.
- TextStyle: Manage font family, size, color, bold, italic, underline, and alignment.
- Shapes: Add and manipulate shapes, including setting size, position, type, and rotation.
- Images: Insert images into slides with options for scaling, alignment, and positioning.
<div class="hsg-featured-snippet">
<h2>PowerPoint Presentation C# Library for .NET</h2>
<ol>
<li><a class="js-modal-open" data-modal-id="trial-license-after-download" href="https://www.nuget.org/packages/IronPPT/">Download the C# library for handling PowerPoint Presentation</a></li>
<li>Create and modify .pptx or .ppt documents</li>
<li>Manage slide properties such as order, visibility, content rotation</li>
<li>Add slide elements such as text, images, and shapes</li>
<li>Style the content with ease</li>
</ol>
</div>
## Installation
### IronPPT Library
Installing IronPPT is quick and straightforward. Add the package using the following method:
```shell
:ProductInstall
```
Alternatively, you can download it directly from the official [IronPPT NuGet website](https://www.nuget.org/packages/IronPPT).
After installation, simply include `using IronPPT;` at the top of your C# code to get started.
## Applying License Key
To use IronPPT, apply a valid license or trial key by setting the **LicenseKey** property. Add the following code immediately after the import statement and before calling any IronPPT methods:
```csharp
/// <summary>
/// This code sets the license key for the IronPPT library.
/// Ensure you have the correct namespace access by installing the IronPPT NuGet package
/// and adjust the license key appropriately for your use case.
/// </summary>
using System; // Required for Console output
using IronPPT; // Ensure the IronPPT library is referenced in your project.
namespace IronPPTApplication
{
class Program
{
public static void Main(string[] args)
{
// Calling the method to set the IronPPT license key.
SetIronPPTLicense();
}
/// <summary>
/// Sets the license key for the IronPPT library to unlock its full features.
/// </summary>
private static void SetIronPPTLicense()
{
// Correctly setting the license for the IronPPT library.
// Replace "IRONPPT.MYLICENSE.KEY.1EF01" with your actual key.
IronPPT.License.LicenseKey = "IRONPPT.MYLICENSE.KEY.1EF01";
// Inform the user that the license key has been set.
Console.WriteLine("IronPPT license key has been set.");
}
}
}
```
## Code Examples
Let's explore some code examples and the features available.
## Create PowerPoint File
Create the PowerPoint presentation by instantiating the `PresentationDocument` class using one of its constructors. Use the `AddSlide` and `AddText` methods to add slides and text, respectively. After that, use the `Save` method to export the PowerPoint presentation.
```csharp
using IronPPT;
// This code demonstrates the creation of a PowerPoint presentation and saving it as a file.
// Create a new PowerPoint presentation document
var document = new PresentationDocument();
// Create a new slide object
var slide = new Slide();
// Add text content to the slide
slide.AddText("Hello!");
// Add the newly created slide with text to the document
document.AddSlide(slide);
// Export the PowerPoint presentation to a file named "output.pptx"
document.Save("output.pptx");
```
## Add Shape
You can use the `AddShape` method from a slide object to add shapes. Various shape properties can be configured, such as fill color, outline color, position, angle, type, and more.
```csharp
using IronPPT;
using IronPPT.Drawing; // Assuming this namespace contains `Shape` and `Color` classes
using IronPPT.Enums; // Assuming this namespace contains the `ShapeType` enum
// Load a PowerPoint presentation from the specified file
var document = new PresentationDocument("output.pptx");
// Create and configure a new shape, in this case, a triangle
Shape shape = new Shape
{
Name = "triangle", // Assign a name to the shape
Type = ShapeType.Triangle, // Set the shape type to Triangle
Width = 100, // Set the width of the shape
Height = 100, // Assumed height for the shape, should be set for visibility
FillColor = new Color("#444444"), // Set the fill color of the shape
OutlineColor = Color.Black, // Set the outline color to black
Position = new System.Drawing.Point(200, 200) // Set the position of the shape
};
// Ensure that the slides array has at least one slide to add the shape to
if (document.Slides.Count > 0)
{
// Add the shape to the first slide
document.Slides[0].AddShape(shape);
}
else
{
// If there are no slides, handle the error or add a slide
document.Slides.Add(new Slide()); // Assuming there's a way to add new slides
document.Slides[0].AddShape(shape); // Add the shape to the newly added slide
}
// Export the PowerPoint presentation to a new file
document.Save("addShape.pptx");
```
## Add Image
Adding an image to any slide is also a simple task. The code example below adds an image to the first slide, modifies the image's properties such as position, angle, name, width, and height, and then saves the updated presentation as a .pptx file.
```csharp
using IronPPT;
using System.Drawing;
// This code demonstrates creating a new PowerPoint presentation, adding an image to it,
// modifying the image's properties, and exporting the presentation.
// Create a new PowerPoint presentation
var document = new PresentationDocument();
// Ensure there's at least one slide in the presentation
// Create the first slide if it doesn't exist yet
if (document.Slides.Count == 0)
{
document.Slides.Add();
}
// Initialize an Image object
// Load an image from a file specified by the file path
// Ensure that "sample.png" exists at the specified path
Image image = new Image();
image.LoadFromFile("sample.png");
// Add the image to the first slide of the presentation
var newImage = document.Slides[0].AddImage(image);
// Edit the image's properties
// Set the position of the image using X and Y coordinates
newImage.Position = new Point(200, 200);
// Set the rotation angle of the image in degrees
newImage.Angle = 45;
// Set a name for the image, which can be useful for identification
newImage.Name = "new image";
// Set the dimensions of the image
newImage.Width = 150;
newImage.Height = 150;
// Export the PowerPoint presentation with the new image
document.Save("addImage.pptx");
```
## Licensing & Support Available
**IronPPT** is a commercial library, but [free trial licenses](trial-license) are available.
For more details about Iron Software, visit our website at: [https://ironsoftware.com/](https://ironsoftware.com/). If you need support or have any inquiries, please [contact our team](https://www.ironsoftware.com/csharp/ppt/#live-chat-support).
### Iron Software Support
For general assistance and technical questions, feel free to email us at: [support@ironsoftware.com](mailto:support@ironsoftware.com).
IronPPT is a PowerPoint library developed by Iron Software. It excels in providing robust functionality for working with PowerPoint presentations in .NET applications.
Load, manipulate, and save PowerPoint presentations. Easily work with .pptx and .ppt files.
SlideSetup: Configure slide size, orientation, background color, and layout.
Text: Handle text content, styles, splitting, appending text, and adding text boxes.
TextStyle: Manage font family, size, color, bold, italic, underline, and alignment.
Shapes: Add and manipulate shapes, including setting size, position, type, and rotation.
Images: Insert images into slides with options for scaling, alignment, and positioning.
Manage slide properties such as order, visibility, content rotation
Add slide elements such as text, images, and shapes
Style the content with ease
Installation
IronPPT Library
Installing IronPPT is quick and straightforward. Add the package using the following method:
PM > Install-Package IronPPT
Install-Package IronPPT
Alternatively, you can download it directly from the official IronPPT NuGet website.
After installation, simply include using IronPPT; at the top of your C# code to get started.
Applying License Key
To use IronPPT, apply a valid license or trial key by setting the LicenseKey property. Add the following code immediately after the import statement and before calling any IronPPT methods:
/// <summary>/// This code sets the license key for the IronPPT library./// Ensure you have the correct namespace access by installing the IronPPT NuGet package/// and adjust the license key appropriately for your use case./// </summary>using System; // Required for Console outputusing IronPPT; // Ensure the IronPPT library is referenced in your project.namespace IronPPTApplication{ class Program { public static voidMain(string[] args) { // Calling the method to set the IronPPT license key.SetIronPPTLicense(); } /// <summary> /// Sets the license key for the IronPPT library to unlock its full features. /// </summary> private static voidSetIronPPTLicense() { // Correctly setting the license for the IronPPT library. // Replace "IRONPPT.MYLICENSE.KEY.1EF01" with your actual key.IronPPT.License.LicenseKey = "IRONPPT.MYLICENSE.KEY.1EF01"; // Inform the user that the license key has been set.Console.WriteLine("IronPPT license key has been set."); } }}
/// <summary>
/// This code sets the license key for the IronPPT library.
/// Ensure you have the correct namespace access by installing the IronPPT NuGet package
/// and adjust the license key appropriately for your use case.
/// </summary>
using System; // Required for Console output
using IronPPT; // Ensure the IronPPT library is referenced in your project.
namespace IronPPTApplication
{
class Program
{
public static void Main(string[] args)
{
// Calling the method to set the IronPPT license key.
SetIronPPTLicense();
}
/// <summary>
/// Sets the license key for the IronPPT library to unlock its full features.
/// </summary>
private static void SetIronPPTLicense()
{
// Correctly setting the license for the IronPPT library.
// Replace "IRONPPT.MYLICENSE.KEY.1EF01" with your actual key.
IronPPT.License.LicenseKey = "IRONPPT.MYLICENSE.KEY.1EF01";
// Inform the user that the license key has been set.
Console.WriteLine("IronPPT license key has been set.");
}
}
}
''' <summary>''' This code sets the license key for the IronPPT library.''' Ensure you have the correct namespace access by installing the IronPPT NuGet package''' and adjust the license key appropriately for your use case.''' </summary>ImportsSystem' Required for Console outputImportsIronPPT' Ensure the IronPPT library is referenced in your project.NamespaceIronPPTApplicationFriend Class Program PublicShared Sub Main(ByVal args() AsString) ' Calling the method to set the IronPPT license key.SetIronPPTLicense() End Sub ''' <summary> ''' Sets the license key for the IronPPT library to unlock its full features. ''' </summary> PrivateShared Sub SetIronPPTLicense() ' Correctly setting the license for the IronPPT library. ' Replace "IRONPPT.MYLICENSE.KEY.1EF01" with your actual key.IronPPT.License.LicenseKey = "IRONPPT.MYLICENSE.KEY.1EF01" ' Inform the user that the license key has been set.Console.WriteLine("IronPPT license key has been set.") End Sub End ClassEndNamespace
''' <summary>
''' This code sets the license key for the IronPPT library.
''' Ensure you have the correct namespace access by installing the IronPPT NuGet package
''' and adjust the license key appropriately for your use case.
''' </summary>
Imports System ' Required for Console output
Imports IronPPT ' Ensure the IronPPT library is referenced in your project.
Namespace IronPPTApplication
Friend Class Program
Public Shared Sub Main(ByVal args() As String)
' Calling the method to set the IronPPT license key.
SetIronPPTLicense()
End Sub
''' <summary>
''' Sets the license key for the IronPPT library to unlock its full features.
''' </summary>
Private Shared Sub SetIronPPTLicense()
' Correctly setting the license for the IronPPT library.
' Replace "IRONPPT.MYLICENSE.KEY.1EF01" with your actual key.
IronPPT.License.LicenseKey = "IRONPPT.MYLICENSE.KEY.1EF01"
' Inform the user that the license key has been set.
Console.WriteLine("IronPPT license key has been set.")
End Sub
End Class
End Namespace
Code Examples
Let's explore some code examples and the features available.
Create PowerPoint File
Create the PowerPoint presentation by instantiating the PresentationDocument class using one of its constructors. Use the AddSlide and AddText methods to add slides and text, respectively. After that, use the Save method to export the PowerPoint presentation.
using IronPPT;// This code demonstrates the creation of a PowerPoint presentation and saving it as a file.// Create a new PowerPoint presentation documentvar document = new PresentationDocument();// Create a new slide objectvar slide = new Slide();// Add text content to the slideslide.AddText("Hello!");// Add the newly created slide with text to the documentdocument.AddSlide(slide);// Export the PowerPoint presentation to a file named "output.pptx"document.Save("output.pptx");
using IronPPT;
// This code demonstrates the creation of a PowerPoint presentation and saving it as a file.
// Create a new PowerPoint presentation document
var document = new PresentationDocument();
// Create a new slide object
var slide = new Slide();
// Add text content to the slide
slide.AddText("Hello!");
// Add the newly created slide with text to the document
document.AddSlide(slide);
// Export the PowerPoint presentation to a file named "output.pptx"
document.Save("output.pptx");
ImportsIronPPT' This code demonstrates the creation of a PowerPoint presentation and saving it as a file.' Create a new PowerPoint presentation documentPrivate document = New PresentationDocument()' Create a new slide objectPrivate slide = New Slide()' Add text content to the slideslide.AddText("Hello!")' Add the newly created slide with text to the documentdocument.AddSlide(slide)' Export the PowerPoint presentation to a file named "output.pptx"document.Save("output.pptx")
Imports IronPPT
' This code demonstrates the creation of a PowerPoint presentation and saving it as a file.
' Create a new PowerPoint presentation document
Private document = New PresentationDocument()
' Create a new slide object
Private slide = New Slide()
' Add text content to the slide
slide.AddText("Hello!")
' Add the newly created slide with text to the document
document.AddSlide(slide)
' Export the PowerPoint presentation to a file named "output.pptx"
document.Save("output.pptx")
Add Shape
You can use the AddShape method from a slide object to add shapes. Various shape properties can be configured, such as fill color, outline color, position, angle, type, and more.
using IronPPT;using IronPPT.Drawing; // Assuming this namespace contains `Shape` and `Color` classesusing IronPPT.Enums; // Assuming this namespace contains the `ShapeType` enum// Load a PowerPoint presentation from the specified filevar document = new PresentationDocument("output.pptx");// Create and configure a new shape, in this case, a triangleShape shape = new Shape{Name = "triangle", // Assign a name to the shapeType = ShapeType.Triangle, // Set the shape type to TriangleWidth = 100, // Set the width of the shapeHeight = 100, // Assumed height for the shape, should be set for visibilityFillColor = new Color("#444444"), // Set the fill color of the shapeOutlineColor = Color.Black, // Set the outline color to blackPosition = new System.Drawing.Point(200, 200) // Set the position of the shape};// Ensure that the slides array has at least one slide to add the shape toif (document.Slides.Count > 0){ // Add the shape to the first slide document.Slides[0].AddShape(shape);}else{ // If there are no slides, handle the error or add a slide document.Slides.Add(new Slide()); // Assuming there's a way to add new slides document.Slides[0].AddShape(shape); // Add the shape to the newly added slide}// Export the PowerPoint presentation to a new filedocument.Save("addShape.pptx");
using IronPPT;
using IronPPT.Drawing; // Assuming this namespace contains `Shape` and `Color` classes
using IronPPT.Enums; // Assuming this namespace contains the `ShapeType` enum
// Load a PowerPoint presentation from the specified file
var document = new PresentationDocument("output.pptx");
// Create and configure a new shape, in this case, a triangle
Shape shape = new Shape
{
Name = "triangle", // Assign a name to the shape
Type = ShapeType.Triangle, // Set the shape type to Triangle
Width = 100, // Set the width of the shape
Height = 100, // Assumed height for the shape, should be set for visibility
FillColor = new Color("#444444"), // Set the fill color of the shape
OutlineColor = Color.Black, // Set the outline color to black
Position = new System.Drawing.Point(200, 200) // Set the position of the shape
};
// Ensure that the slides array has at least one slide to add the shape to
if (document.Slides.Count > 0)
{
// Add the shape to the first slide
document.Slides[0].AddShape(shape);
}
else
{
// If there are no slides, handle the error or add a slide
document.Slides.Add(new Slide()); // Assuming there's a way to add new slides
document.Slides[0].AddShape(shape); // Add the shape to the newly added slide
}
// Export the PowerPoint presentation to a new file
document.Save("addShape.pptx");
ImportsIronPPTImportsIronPPT.Drawing' Assuming this namespace contains `Shape` and `Color` classesImportsIronPPT.Enums' Assuming this namespace contains the `ShapeType` enum' Load a PowerPoint presentation from the specified filePrivate document = New PresentationDocument("output.pptx")' Create and configure a new shape, in this case, a trianglePrivate shape As New ShapeWith { .Name = "triangle", .Type = ShapeType.Triangle, .Width = 100, .Height = 100, .FillColor = New Color("#444444"), .OutlineColor = Color.Black, .Position = New System.Drawing.Point(200, 200)}' Ensure that the slides array has at least one slide to add the shape toIf document.Slides.Count > 0 Then ' Add the shape to the first slide document.Slides(0).AddShape(shape)Else ' If there are no slides, handle the error or add a slide document.Slides.Add(New Slide()) ' Assuming there's a way to add new slides document.Slides(0).AddShape(shape) ' Add the shape to the newly added slideEnd If' Export the PowerPoint presentation to a new filedocument.Save("addShape.pptx")
Imports IronPPT
Imports IronPPT.Drawing ' Assuming this namespace contains `Shape` and `Color` classes
Imports IronPPT.Enums ' Assuming this namespace contains the `ShapeType` enum
' Load a PowerPoint presentation from the specified file
Private document = New PresentationDocument("output.pptx")
' Create and configure a new shape, in this case, a triangle
Private shape As New Shape With {
.Name = "triangle",
.Type = ShapeType.Triangle,
.Width = 100,
.Height = 100,
.FillColor = New Color("#444444"),
.OutlineColor = Color.Black,
.Position = New System.Drawing.Point(200, 200)
}
' Ensure that the slides array has at least one slide to add the shape to
If document.Slides.Count > 0 Then
' Add the shape to the first slide
document.Slides(0).AddShape(shape)
Else
' If there are no slides, handle the error or add a slide
document.Slides.Add(New Slide()) ' Assuming there's a way to add new slides
document.Slides(0).AddShape(shape) ' Add the shape to the newly added slide
End If
' Export the PowerPoint presentation to a new file
document.Save("addShape.pptx")
Add Image
Adding an image to any slide is also a simple task. The code example below adds an image to the first slide, modifies the image's properties such as position, angle, name, width, and height, and then saves the updated presentation as a .pptx file.
using IronPPT;using System.Drawing;// This code demonstrates creating a new PowerPoint presentation, adding an image to it,// modifying the image's properties, and exporting the presentation.// Create a new PowerPoint presentationvar document = new PresentationDocument();// Ensure there's at least one slide in the presentation// Create the first slide if it doesn't exist yetif (document.Slides.Count == 0){ document.Slides.Add();}// Initialize an Image object// Load an image from a file specified by the file path// Ensure that "sample.png" exists at the specified pathImage image = new Image(); image.LoadFromFile("sample.png");// Add the image to the first slide of the presentationvar newImage = document.Slides[0].AddImage(image);// Edit the image's properties// Set the position of the image using X and Y coordinatesnewImage.Position = new Point(200, 200);// Set the rotation angle of the image in degreesnewImage.Angle = 45;// Set a name for the image, which can be useful for identificationnewImage.Name = "new image";// Set the dimensions of the imagenewImage.Width = 150;newImage.Height = 150;// Export the PowerPoint presentation with the new imagedocument.Save("addImage.pptx");
using IronPPT;
using System.Drawing;
// This code demonstrates creating a new PowerPoint presentation, adding an image to it,
// modifying the image's properties, and exporting the presentation.
// Create a new PowerPoint presentation
var document = new PresentationDocument();
// Ensure there's at least one slide in the presentation
// Create the first slide if it doesn't exist yet
if (document.Slides.Count == 0)
{
document.Slides.Add();
}
// Initialize an Image object
// Load an image from a file specified by the file path
// Ensure that "sample.png" exists at the specified path
Image image = new Image();
image.LoadFromFile("sample.png");
// Add the image to the first slide of the presentation
var newImage = document.Slides[0].AddImage(image);
// Edit the image's properties
// Set the position of the image using X and Y coordinates
newImage.Position = new Point(200, 200);
// Set the rotation angle of the image in degrees
newImage.Angle = 45;
// Set a name for the image, which can be useful for identification
newImage.Name = "new image";
// Set the dimensions of the image
newImage.Width = 150;
newImage.Height = 150;
// Export the PowerPoint presentation with the new image
document.Save("addImage.pptx");
ImportsIronPPTImportsSystem.Drawing' This code demonstrates creating a new PowerPoint presentation, adding an image to it,' modifying the image's properties, and exporting the presentation.' Create a new PowerPoint presentationPrivate document = New PresentationDocument()' Ensure there's at least one slide in the presentation' Create the first slide if it doesn't exist yetIf document.Slides.Count = 0 Then document.Slides.Add()End If' Initialize an Image object' Load an image from a file specified by the file path' Ensure that "sample.png" exists at the specified pathDim image As New Image()image.LoadFromFile("sample.png")' Add the image to the first slide of the presentationDim newImage = document.Slides(0).AddImage(image)' Edit the image's properties' Set the position of the image using X and Y coordinatesnewImage.Position = New Point(200, 200)' Set the rotation angle of the image in degreesnewImage.Angle = 45' Set a name for the image, which can be useful for identificationnewImage.Name = "new image"' Set the dimensions of the imagenewImage.Width = 150newImage.Height = 150' Export the PowerPoint presentation with the new imagedocument.Save("addImage.pptx")
Imports IronPPT
Imports System.Drawing
' This code demonstrates creating a new PowerPoint presentation, adding an image to it,
' modifying the image's properties, and exporting the presentation.
' Create a new PowerPoint presentation
Private document = New PresentationDocument()
' Ensure there's at least one slide in the presentation
' Create the first slide if it doesn't exist yet
If document.Slides.Count = 0 Then
document.Slides.Add()
End If
' Initialize an Image object
' Load an image from a file specified by the file path
' Ensure that "sample.png" exists at the specified path
Dim image As New Image()
image.LoadFromFile("sample.png")
' Add the image to the first slide of the presentation
Dim newImage = document.Slides(0).AddImage(image)
' Edit the image's properties
' Set the position of the image using X and Y coordinates
newImage.Position = New Point(200, 200)
' Set the rotation angle of the image in degrees
newImage.Angle = 45
' Set a name for the image, which can be useful for identification
newImage.Name = "new image"
' Set the dimensions of the image
newImage.Width = 150
newImage.Height = 150
' Export the PowerPoint presentation with the new image
document.Save("addImage.pptx")
Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.