Spire.Presentation Quick Start

In this document, we will quickly help you finish a simple demo about Spire.Presentation using Visual Studio. As usual, it's a HelloWorld demo. Before you get started, please make sure the Spire.Presentation and Visual Studio (2005 or later) are installed on your computer.

1. In Visual Studio, click, File, New, and then Project. If you want to create a C# project, select Visual C#, Windows and choose Windows Forms Application and name the project HelloWorld. Click OK. If you want to create a Visual Basic project, select Visual Basic, Windows Forms Application and name the project HelloWorld. Click OK.

2. In Solution Explorer, right-click the project HelloWorld and click Add Reference. In the Browse tab, find the folder which you installed the Spire.Presentation in, default is "C:\ProgramFiles\e-iceblue\ Spire.Presentation", double-click the folder Bin. If the target framework of the project HelloWorld

  • is .NET 2.0, double-click folder NET2.0
  • is .NET 3.5, double-click folder NET3.5
  • is .NET 4.0, double-click folder NET4.0

Select assembly Spire.Presentation.dll and click OK to add it to the project.

3. In Solution Explorer, double-click the file Form1.cs/Form1.vb to open the form design view, add a button into the form, and change its name to 'btnRun', change its text to 'Run'.

4. Double-click the button 'Run', you will see the code view and the following method has been added automatically:

[C#]
private void btnRun_Click(object sender, EventArgs e)
[VB.NET]
Private Sub btnRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRun.Click

5. Add the following codes to the top of the file:

[C#]
using  Spire.Presentation;
using  Spire.Presentation.Drawing;
[VB.NET]
Imports  Spire.Presentation
Imports  Spire.Presentation.Drawing

6. Add the following codes to the method btnRun_Click

[C#]
//create PPT document
Presentation  presentation = new Presentation();  
//add new shape to PPT document           
IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle,
					new RectangleF(0, 50, 200, 50));
shape.ShapeStyle.LineColor.Color = Color.White;
shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;  
//add text to shape
shape.AppendTextFrame("Hello World!");   
//set the Font fill style of text  
TextRange textRange = shape.TextFrame.TextRange;
textRange.Fill.FillType = Presentation.Drawing.FillFormatType.Solid;
textRange.Fill.SolidColor.Color = Color.Black;  
textRange.LatinFont = new TextFont("Arial Black");  
//save the document
presentation.SaveToFile("hello.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("hello.pptx");
[VB.NET]
'create PPT document  
Dim presentation As New Presentation()   
'add new shape to PPT document
Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(0, 50, 200, 50)    
shape.ShapeStyle.LineColor.Color = Color.White
shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None  
'add text to shape  
shape.AppendTextFrame("Hello World!")  
'set the Font fill style of text
Dim textRange As TextRange = shape.TextFrame.TextRange
textRange.Fill.FillType =  Spire.Presentation.Drawing.FillFormatType.Solid
textRange.Fill.SolidColor.Color = Color.Black
textRange.LatinFont = New TextFont("Arial Black")  
'save the document
presentation.SaveToFile("hello.pptx", FileFormat.Pptx2010)
System.Diagnostics.Process.Start("hello.pptx")

7. In Solution Explorer, right-click the project HelloWorld and click Debug, then Start new instance, you will see the opened window Form1, click the button 'Run', a PPT document will be created, edited and opened. The string "Hello, World" is filled in the first page.

The following screenshot is result of the project ran:

Spire.Presentation Quick Start