C#: Change the Slide Order in a PowerPoint Document
Optimizing the order of slides in a PowerPoint presentation is a simple skill. By rearranging slides, you can refine the logic and flow of your presentation, group related points together, or move slides to more impactful locations. This flexibility enables you to create a cohesive, engaging narrative that captivates your audience.
This article demonstrates how to programmatically change the slide order in a PowerPoint document in C# by using the Spire.Presentation for .NET library.
Install Spire.Presentation for .NET
To begin with, you need to add the DLL files included in the Spire.Presentation for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.Presentation
Change the Slide Order in a PowerPoint Document in C#
To reorder slides in a PowerPoint presentation, create two Presentation objects - one to load the original document and another to create a new document. By copying the slides from the original document to the new one in the desired sequence, you can easily rearrange the slide order.
The steps to rearrange slides in a PowerPoint document using C# are as follows.
- Create a Presentation object.
- Load a PowerPoint document using Presentation.LoadFromFile() method.
- Specify the slide order within an array.
- Create another Presentation object for creating a new presentation.
- Add the slides from the original document to the new presentation in the specified order using Presentation.Slides.Append() method.
- Save the new presentation to a PPTX file using Presentation.SaveToFile() method.
- C#
using Spire.Presentation;
namespace ChangeSlideOrder
{
class Program
{
static void Main(string[] args)
{
// Create a Presentation object
Presentation presentation = new Presentation();
// Load a PowerPoint file
presentation.LoadFromFile("C:\\Users\\Administrator\\Desktop\\input.pptx");
// Specify the new slide order within an array
int[] newSlideOrder = new int[] { 4, 2, 1, 3 };
// Create another Presentation object
Presentation new_presentation = new Presentation();
// Remove the default slide
new_presentation.Slides.RemoveAt(0);
// Iterate through the array
for (int i = 0; i < newSlideOrder.Length; i++)
{
// Add the slides from the original PowerPoint file to the new PowerPoint document in the new order
new_presentation.Slides.Append(presentation.Slides[newSlideOrder[i] - 1]);
}
// Save the new presentation to file
new_presentation.SaveToFile("NewOrder.pptx", FileFormat.Pptx2019);
// Dispose resources
presentation.Dispose();
new_presentation.Dispose();
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
Save PowerPoint file to Stream and Load PowerPoint file from Stream
Spire.Presentation is a powerful and easy-to-use .NET component, especially designed for developers. Using Spire.Presentation you can generate, modify, convert, render, and print documents without installing Microsoft PowerPoint on your machine. In this document, I will introduce you how to create PowerPoint file and save it to stream. I also introduce you how to load PowerPoint file from stream. Check it below.
Create PowerPoint file and save it to Stream
Step 1: Create Presentation instance.
Presentation presentation = new Presentation();
Step 2: Set background image.
string ImageFile = "bg.png"; RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height); presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect); presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;
Step 3: Add text to PowerPoint document.
IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 450, 150)); shape.Fill.FillType = FillFormatType.None; shape.ShapeStyle.LineColor.Color = Color.White; //add text to shape shape.TextFrame.Text = "This demo shows how to Create PowerPoint file and save it to Stream."; shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = FillFormatType.Solid; shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.Black;
Step 4: Save document to stream.
FileStream to_stream = new FileStream("To_stream.pptx", FileMode.Create);
presentation.SaveToFile(to_stream, FileFormat.Pptx2010);
to_stream.Close();
Preview the generated PowerPoint file:

Load PowerPoint file from stream.
Step 1: Create Presentation instance.
Presentation presentationLoad = new Presentation();
Step 2: Load PowerPoint file from stream.
FileStream from_stream = File.OpenRead("sample.pptx");
presentationLoad.LoadFromStream(from_stream, FileFormat.Pptx2010);
Step 3: Save the document.
presentationLoad.SaveToFile("From_stream.pptx",FileFormat.Pptx2010);
from_stream.Dispose();
Preview the PowerPoint file:

Full code:
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
using System.IO;
namespace SavePPTtoStream
{
class Program
{
static void Main(string[] args)
{
//A: create PowerPoint file and save it to stream
Presentation presentation = new Presentation();
//set background Image
string ImageFile = "bg.png";
RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);
presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);
presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;
//append new shape
IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 450, 150));
shape.Fill.FillType = FillFormatType.None;
shape.ShapeStyle.LineColor.Color = Color.White;
//add text to shape
shape.TextFrame.Text = "This demo shows how to Create PowerPoint file and save it to Stream.";
shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = FillFormatType.Solid;
shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.Black;
//save to Stream
FileStream to_stream = new FileStream("To_stream.pptx", FileMode.Create);
presentation.SaveToFile(to_stream, FileFormat.Pptx2010);
to_stream.Close();
System.Diagnostics.Process.Start("To_stream.pptx");
//B: Load PowerPoint file from Stream
Presentation presentationLoad = new Presentation();
//load PowerPoint file from stream
FileStream from_stream = File.OpenRead("sample.pptx");
presentationLoad.LoadFromStream(from_stream, FileFormat.Pptx2010);
//save the document
presentationLoad.SaveToFile("From_stream.pptx", FileFormat.Pptx2010);
from_stream.Dispose();
System.Diagnostics.Process.Start("From_stream.pptx");
}
}
}
If you couldn't successfully use Spire.Presentation, please refer Spire.Presentation Quick Start which can guide you quickly use Spire.Presentation.
How to Remove Slides from a Presentation
Sometimes, we may need to delete specific slide in a PowerPoint presentation due to any reason. This section will illustrate that how we can accomplish that task using Spire.Presentation for .NET.
As a matter of fact, it is quite easy and convenient to remove slides by only one line of core code if you have Spire.Presentation.Dll installed as a reference in your .NET project assemblies. Here is the method:
Step 1: Create an instance of presentation class and load PPT documents
Presentation presentation = new Presentation();
presentation.LoadFromFile("sample.pptx");
Step 2: Remove the second slide from the presentation by using its index position
presentation.Slides.RemoveAt(1);
Step 3: Save and review
presentation.SaveToFile("result.pptx",FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");
Original layout:

Result:

Full C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Presentation;
namespace RemoveSlide
{
class Program
{
static void Main(string[] args)
{
Presentation presentation = new Presentation();
presentation.LoadFromFile("sample.pptx");
//remove the second slide
presentation.Slides.RemoveAt(1);
presentation.SaveToFile("result.pptx",FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");
}
}
}
C#: Change Slide Size in PowerPoint
Changing slide size is one way to maintain the visual integrity of your PowerPoint presentation. By adjusting the slide size to the specific aspect ratio and dimensions of the target screen or projection device, you can avoid issues such as content appearing cropped, stretched, or distorted. In this article, you will learn how to change the slide size of a PowerPoint presentation in C# using Spire.Presentation for .NET.
Install Spire.Presentation for .NET
To begin with, you need to add the DLL files included in the Spire.Presentation for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.Presentation
Change the Slide Size to a Preset Size in C#
Spire.Presentation for .NET provides the Presentation.SlideSize.Type property to set or change the slide size to a preset size. The following are the detailed steps.
- Create a Presentation instance.
- Load a PowerPoint presentation using Presentation.LoadFromFile() method.
- Change the slide type of the presentation using Presentation.SlideSize.Type property.
- Save the result document using Presentation.SaveToFile() method.
- C#
using Spire.Presentation;
namespace CreateCombination
{
class Program
{
static void Main(string[] args)
{
//Create a Presentation instance
Presentation ppt = new Presentation();
//Load a presentation file
ppt.LoadFromFile("sample.pptx");
//Change the slide size of the presentation
ppt.SlideSize.Type = SlideSizeType.Screen4x3;
//Save the result file
ppt.SaveToFile("SlideSize.pptx", FileFormat.Pptx2013);
ppt.Dispose();
}
}
}

Change the Slide Size to a Custom Size in C#
Customizing the size of slides requires changing the slide size type to Custom first, and then you can set a desired size through the Presentation.SlideSize.Size property. The following are the detailed steps.
- Create a Presentation instance.
- Load a PowerPoint presentation using Presentation.LoadFromFile() method.
- Change the slide size type to custom using Presentation.SlideSize.Type property.
- Customize the slide size using Presentation.SlideSize.Size property.
- Save the result document using Presentation.SaveToFile() method.
- C#
using Spire.Presentation;
using System.Drawing;
namespace CreateCombination
{
class Program
{
static void Main(string[] args)
{
//Create a Presentation instance
Presentation ppt = new Presentation();
//Load a presentation file
ppt.LoadFromFile("sample.pptx");
//Change the slide size type to custom
ppt.SlideSize.Type = SlideSizeType.Custom;
//Set the slide size
ppt.SlideSize.Size = new SizeF(900, 600);
//Save the presentation file
ppt.SaveToFile("CustomSize.pptx", FileFormat.Pptx2013);
ppt.Dispose();
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
C#/VB.NET: Add or Delete Slides in PowerPoint
Slides are the most basic component of a PowerPoint document. Each PowerPoint presentation can be composed of a series of slides containing different elements, such as text, shapes, tables, and images. When you are working on a PowerPoint document, adding and removing slides are probably some of the most required actions. In this article, you will learn how to programmatically add or delete a PowerPoint slide using Spire.Presentation for .NET.
- Add a New Slide at the End of the PowerPoint Document
- Insert a New Slide Before a Specific Slide in PowerPoint
- Delete a Specific Slide from a PowerPoint Document
Install Spire.Presentation for .NET
To begin with, you need to add the DLL files included in the Spire.Presentation for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.Presentation
Add a New Slide at the End of the PowerPoint Document
The Presentation.Slides.Append() method provided by Spire.Presentation for .NET allows you to append a new slide after the last slide of a PowerPoint document. The detailed steps are as follows.
- Initialize an instance of Presentation class.
- Load a PowerPoint document using Presentation.LoadFromFile() method.
- Add a new blank slide at the end of the document using Presentation.Slides.Append() method.
- Save the result document using Presentation.SaveToFile() method.
- C#
- VB.NET
using Spire.Presentation;
namespace AddNewSlideinPowerPoint
{
class Program
{
static void Main(string[] args)
{
// Initialize an instance of Presentation class
Presentation presentation = new Presentation();
//Load a sample PowerPoint document
presentation.LoadFromFile("Sample.pptx");
//Add a new slide at the end of the document
presentation.Slides.Append();
//Save the result document
presentation.SaveToFile("AddSlide.pptx", FileFormat.Pptx2013);
}
}
}

Insert a New Slide Before a Specific Slide in PowerPoint
Sometimes you may also need to insert a slide before a specific slide to add additional supporting information, and below are the detailed steps to accomplish the task.
- Initialize an instance of Presentation class.
- Load a PowerPoint document using Presentation.LoadFromFile() method.
- Insert a blank slide before a specified slide using Presentation.Slides.Insert() method.
- Save the result document using Presentation.SaveToFile() method.
- C#
- VB.NET
using Spire.Presentation;
namespace InsertSlideinPowerPoint
{
class Program
{
static void Main(string[] args)
{
//Create a Presentation object
Presentation presentation = new Presentation();
//Load a sample PowerPoint document
presentation.LoadFromFile("Sample.pptx");
//Insert a blank slide before the second slide
presentation.Slides.Insert(1);
//Save the result document
presentation.SaveToFile("InsertSlide.pptx", FileFormat.Pptx2013);
}
}
}

Delete a Specific Slide from a PowerPoint Document
If you want to remove a unnecessary slide from the document, you can use the Presentation.Slides.RemoveAt(int index) method. The detailed steps are as follows.
- Initialize an instance of Presentation class.
- Load a PowerPoint document using Presentation.LoadFromFile() method.
- Remove a specified slide from the document using Presentation.Slides.RemoveAt() method.
- Save the result document using Presentation.SaveToFile() method.
- C#
- VB.NET
using Spire.Presentation;
namespace DeletePowerPointSlide
{
class Program
{
static void Main(string[] args)
{
//Create a Presentation object
Presentation presentation = new Presentation();
//Load a sample PowerPoint document
presentation.LoadFromFile("Sample.pptx");
//Remove the first slide
presentation.Slides.RemoveAt(0);
//Save the result document
presentation.SaveToFile("RemoveSlide.pptx", FileFormat.Pptx2013);
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
C#/VB.NET: Set Background Color or Picture for PowerPoint Slides
Setting a background for slides is a crucial step in creating a visually appealing and impactful presentation. A well-designed background can provide a consistent visual theme, drawing your audience's attention and keeping them engaged throughout your presentation. In this article, we will demonstrate how to set background color or picture for PowerPoint slides in C# and VB.NET using Spire.Presentation for .NET library.
- Set a Background Color for a PowerPoint Slide in C# and VB.NET
- Set a Gradient Background for a PowerPoint Slide in C# and VB.NET
- Set a Background Picture for a PowerPoint Slide in C# and VB.NET
- Set a Background for a Slide Master in PowerPoint in C# and VB.NET
Install Spire.Presentation for .NET
To begin with, you need to add the DLL files included in the Spire.Presentation for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.Presentation
Set a Background Color for a PowerPoint Slide in C# and VB.NET
Adding a background color for a PowerPoint slide is very simple. You just need to set the fill mode of the slide’s background as a solid fill and then set a color for the slide’s background. The detailed steps are as follows:
- Initialize an instance of the Presentation class.
- Load a PowerPoint presentation using Presentation.LoadFromFile() method.
- Get a specific slide using Presentation.Slides[int index] property.
- Access the background of the slide using ISlide.SlideBackground property.
- Set the type of the slide's background as a custom type using SlideBackground.Type property.
- Set the fill mode of the slide’s background as a solid fill using SlideBackground.Fill.FillType property.
- Set a color for the slide’s background using SlideBackground.Fill.SolidColor.Color property.
- Save the result presentation using Presentation.SaveToFile() method.
- C#
- VB.NET
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace SolidBackground
{
internal class Program
{
static void Main(string[] args)
{
//Initialize an instance of the Presentation class
Presentation ppt = new Presentation();
//Load a PowerPoint presentation
ppt.LoadFromFile("Sample.pptx");
//Get the first slide
ISlide slide = ppt.Slides[0];
//Access the background of the slide
SlideBackground background = slide.SlideBackground;
//Set the type of the slide's background as a custom type
background.Type = BackgroundType.Custom;
//Set the fill mode of the slide's background as a solid fill
background.Fill.FillType = FillFormatType.Solid;
//Set a color for the slide's background
background.Fill.SolidColor.Color = Color.PaleTurquoise;
//Save the result presentation
ppt.SaveToFile("Solidbackground.pptx", FileFormat.Pptx2013);
ppt.Dispose();
}
}
}

Set a Gradient Background for a PowerPoint Slide in C# and VB.NET
Adding a gradient background is a little complex. You need to set the fill mode of the slide’s background as a gradient fill and then set the gradient stops and colors. The detailed steps are as follows:
- Initialize an instance of the Presentation class.
- Load a PowerPoint presentation using Presentation.LoadFromFile() method.
- Get a specific slide using Presentation.Slides[int index] property.
- Access the background of the slide using ISlide.SlideBackground property.
- Set the type of the slide's background as a custom type using SlideBackground.Type property.
- Set the fill mode of the slide’s background as a gradient fill using SlideBackground.Fill.FillType property.
- Set gradient stops and colors for the slide’s background using SlideBackground.Fill.Gradient.GradientStops.Append() method.
- Set the shape type and angle for the gradient fill.
- Save the result presentation using Presentation.SaveToFile() method.
- C#
- VB.NET
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace GradientBackground
{
internal class Program
{
static void Main(string[] args)
{
//Initialize an instance of the Presentation class
Presentation ppt = new Presentation();
//Load a PowerPoint presentation
ppt.LoadFromFile("Sample.pptx");
//Get the first slide
ISlide slide = ppt.Slides[0];
//Access the background of the slide
SlideBackground background = slide.SlideBackground;
//Set the type of the slide's background as a custom type
background.Type = BackgroundType.Custom;
//Set the fill mode of the slide's background as a gradient fill
background.Fill.FillType = FillFormatType.Gradient;
//Set gradient stops and colors
background.Fill.Gradient.GradientStops.Append(0.1f, Color.LightCyan);
background.Fill.Gradient.GradientStops.Append(0.7f, Color.LightSeaGreen);
//Set the shape type of the gradient fill
background.Fill.Gradient.GradientShape = GradientShapeType.Linear;
//Set the angle of the gradient fill
background.Fill.Gradient.LinearGradientFill.Angle = 45;
//Save the result presentation
ppt.SaveToFile("Gradientbackground.pptx", FileFormat.Pptx2013);
ppt.Dispose();
}
}
}

Set a Background Picture for a PowerPoint Slide in C# and VB.NET
To add a background picture for a PowerPoint slide, you need to set the fill mode of the slide’s background as a picture fill, then add a picture to the image collection of the presentation and set it as the slide’s background. The detailed steps are as follows:
- Initialize an instance of the Presentation class.
- Load a PowerPoint presentation using Presentation.LoadFromFile() method.
- Get a specific slide using Presentation.Slides[int index] property.
- Access the background of the slide using ISlide.SlideBackground property.
- Set the type of the slide's background as a custom type using SlideBackground.Type property.
- Set the fill mode of the slide’s background as a picture fill using SlideBackground.Fill.FillType property.
- Add an image to the image collection of the presentation using Presentation.Images.Append() method.
- Set the image as the slide’s background using background.Fill.PictureFill.Picture.EmbedImage property.
- Save the result presentation using Presentation.SaveToFile() method.
- C#
- VB.NET
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace PictureBackground
{
internal class Program
{
static void Main(string[] args)
{
//Initialize an instance of the Presentation class
Presentation ppt = new Presentation();
//Load a PowerPoint presentation
ppt.LoadFromFile("Sample.pptx");
//Get the first slide
ISlide slide = ppt.Slides[0];
//Access the background of the slide
SlideBackground background = slide.SlideBackground;
//Set the type of the slide's background as a custom type
background.Type = BackgroundType.Custom;
//Set the fill mode of the slide's background as a picture fill
background.Fill.FillType = FillFormatType.Picture;
Image img = Image.FromFile("bg.jpg");
//Add an image to the image collection of the presentation
IImageData image = ppt.Images.Append(img);
//Set the image as the slide's background
background.Fill.PictureFill.FillType = PictureFillType.Stretch;
background.Fill.PictureFill.Picture.EmbedImage = image;
//Save the result presentation
ppt.SaveToFile("Picturebackground.pptx", FileFormat.Pptx2013);
ppt.Dispose();
}
}
}

Set a Background for a Slide Master in PowerPoint in C# and VB.NET
If you don’t wish to set backgrounds for slides one by one, you can set a background for the slide master, then all slides using the same slide master will be applied with the background automatically. The following steps show how to set a solid background color for a slide master:
- Initialize an instance of the Presentation class.
- Load a PowerPoint presentation using Presentation.LoadFromFile() method.
- Get a specific slide master using Presentation.Masters[int index] property.
- Access the background of the slide using ISlide.SlideBackground property.
- Set the type of the slide's background as a custom type using SlideBackground.Type property.
- Set the fill mode of the slide’s background as a solid fill using SlideBackground.Fill.FillType property.
- Set a color for the slide’s background using SlideBackground.Fill.SolidColor.Color property.
- Save the result presentation using Presentation.SaveToFile() method.
- C#
- VB.NET
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace AddBackgroundToSlideMaster
{
internal class Program
{
static void Main(string[] args)
{
//Initialize an instance of the Presentation class
Presentation ppt = new Presentation();
//Load a PowerPoint presentation
ppt.LoadFromFile("Sample.pptx");
//Get the first slide master
IMasterSlide slide = ppt.Masters[0];
//Access the background of the slide
SlideBackground background = slide.SlideBackground;
//Set the type of the slide's background as a custom type
background.Type = BackgroundType.Custom;
//Set the fill mode of the slide's background as a solid fill
background.Fill.FillType = FillFormatType.Solid;
//Set a color for the slide's background
background.Fill.SolidColor.Color = Color.PeachPuff;
//Save the result presentation
ppt.SaveToFile("AddBackgroundToSlideMaster.pptx", FileFormat.Pptx2013);
ppt.Dispose();
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
Set the properties of the PowerPoint document
Spire.Presentation, a professional .NET component especially designed for developers enables you to manipulate PPT files easily and flexibly. Using Spire.Presentation you can generate, modify, convert, render, and print documents without installing Microsoft PowerPoint on your machine. You can also set the properties of PPT document using Spire.Presentation. And it is a quiet an easy work. Here I will show you how to do so.
Step 1: Create a PPT document.
Presentation presentation = new Presentation();
Step 2: Add some context to PPT document such as image and text.
Step 3: Set the properties of the PPT document.
presentation.DocumentProperty.Application = "Spire.Presentation"; presentation.DocumentProperty.Author = "http://www.e-iceblue.com/"; presentation.DocumentProperty.Company = "E-iceblue"; presentation.DocumentProperty.Keywords = "Demo File"; presentation.DocumentProperty.Comments = "This file tests Spire.Presentation."; presentation.DocumentProperty.Category = "Demo"; presentation.DocumentProperty.Title = "This is a demo file."; presentation.DocumentProperty.Subject = "Test";
Step 4: Save the PPT document.
presentation.SaveToFile("para.pptx", FileFormat.Pptx2010);
Screenshot:

Full code:
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace SetProperties
{
class Program
{
static void Main(string[] args)
{
//create PPT document
Presentation presentation = new Presentation();
//set background Image
string ImageFile = "bg.png";
RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);
presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);
presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;
//set the DocumentProperty of PPT document
presentation.DocumentProperty.Application = "Spire.Presentation";
presentation.DocumentProperty.Author = "http://www.e-iceblue.com/";
presentation.DocumentProperty.Company = "E-iceblue";
presentation.DocumentProperty.Keywords = "Demo File";
presentation.DocumentProperty.Comments = "This file tests Spire.Presentation.";
presentation.DocumentProperty.Category = "Demo";
presentation.DocumentProperty.Title = "This is a demo file.";
presentation.DocumentProperty.Subject = "Test";
//append new shape
IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 600, 250));
shape.ShapeStyle.LineColor.Color = Color.White;
shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;
//add text to shape
shape.AppendTextFrame("The sample demonstrates how to Set DocumentProperty of PPT using Spire.Presentation.");
//add new paragraph
shape.TextFrame.Paragraphs.Append(new TextParagraph());
//add text to paragraph
shape.TextFrame.Paragraphs[1].TextRanges.Append(new TextRange("Spire.Office for .NET is a compilation of Enterprise-Level Office .NET component offered by E-iceblue. It includes Spire.Doc, Spire XLS, Spire.PDF, Spire.DataExport, Spire.PDFViewer, Spire.DocViewer, and Spire.BarCode. Spire.Office contains the most up-to-date versions of the above .NET components."));
//set the Font
foreach (TextParagraph para in shape.TextFrame.Paragraphs)
{
para.TextRanges[0].LatinFont = new TextFont("Arial Rounded MT Bold");
para.TextRanges[0].Fill.FillType = FillFormatType.Solid;
para.TextRanges[0].Fill.SolidColor.Color = Color.Black;
para.Alignment = TextAlignmentType.Left;
para.Indent = 35;
}
//save the document
presentation.SaveToFile("DocumentProperty.pptx", FileFormat.Pptx2007);
System.Diagnostics.Process.Start("DocumentProperty.pptx");
}
}
}
Imports Spire.Presentation
Imports Spire.Presentation.Drawing
Imports System.Drawing
Namespace SetProperties
Class Program
Private Shared Sub Main(args As String())
'create PPT document
Dim presentation As New Presentation()
'set background Image
Dim ImageFile As String = "bg.png"
Dim rect As New RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height)
presentation.Slides(0).Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect)
presentation.Slides(0).Shapes(0).Line.FillFormat.SolidFillColor.Color = Color.FloralWhite
'set the DocumentProperty of PPT document
presentation.DocumentProperty.Application = "Spire.Presentation"
presentation.DocumentProperty.Author = "http://www.e-iceblue.com/"
presentation.DocumentProperty.Company = "E-iceblue"
presentation.DocumentProperty.Keywords = "Demo File"
presentation.DocumentProperty.Comments = "This file tests Spire.Presentation."
presentation.DocumentProperty.Category = "Demo"
presentation.DocumentProperty.Title = "This is a demo file."
presentation.DocumentProperty.Subject = "Test"
'append new shape
Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(50, 70, 600, 250))
shape.ShapeStyle.LineColor.Color = Color.White
shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None
'add text to shape
shape.AppendTextFrame("The sample demonstrates how to Set DocumentProperty of PPT using Spire.Presentation.")
'add new paragraph
shape.TextFrame.Paragraphs.Append(New TextParagraph())
'add text to paragraph
shape.TextFrame.Paragraphs(1).TextRanges.Append(New TextRange("Spire.Office for .NET is a compilation of Enterprise-Level Office .NET component offered by E-iceblue. It includes Spire.Doc, Spire XLS, Spire.PDF, Spire.DataExport, Spire.PDFViewer, Spire.DocViewer, and Spire.BarCode. Spire.Office contains the most up-to-date versions of the above .NET components."))
'set the Font
For Each para As TextParagraph In shape.TextFrame.Paragraphs
para.TextRanges(0).LatinFont = New TextFont("Arial Rounded MT Bold")
para.TextRanges(0).Fill.FillType = FillFormatType.Solid
para.TextRanges(0).Fill.SolidColor.Color = Color.Black
para.Alignment = TextAlignmentType.Left
para.Indent = 35
Next
'save the document
presentation.SaveToFile("DocumentProperty.pptx", FileFormat.Pptx2007)
System.Diagnostics.Process.Start("DocumentProperty.pptx")
End Sub
End Class
End Namespace