PPT text Alignment can be taken as one kind of text format tools. It allows users to align text with the following styles: Left, Right, Center and Justify. By default, text will be aligned right. Also, users can customize alignment. Below demonstrate the effect by a screenshot which shows the text is corresponding to the alignment, for example, text Left is aligned left and Center is aligned center.

Align Text in PPT Document

Spire.Presentation for .NET, a professional .NET PPT component to allow users to manipulate PPT documents without automation. This guide will introduce a method to align text with C#, VB.NET via Spire.Presentation for .NET.

The method is:

First, new a PPT document, and set its slide. Then, traversal all alignment and use the new paragraph to show them. Last set the font and fill style for added paragraphs.

Download and install Spire.Presentation for .NET and use below code to experience this method to align text in PPT document.

The full code:

[C#]
using System;
using System.Drawing;
using Spire.Presentation;
using Spire.Presentation.Drawing;

namespace Alignment
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation presentation = new Presentation();


            //set background Image
            string ImageFile = @"bg.png";
            // set the rectangle size and position
            RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);     
    //set the slide's shapes,background image and rectangle .
            presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);
            //set the shape's solidFillColor 
            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, 600, 400));

            shape.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Left;
            shape.Fill.FillType = FillFormatType.None;
            shape.TextFrame.Text = "Demo about Alignment";

            foreach (TextAlignmentType textAlign in Enum.GetValues(typeof(TextAlignmentType)))
            {
                //create a text range
                TextRange textRange = new TextRange(textAlign.ToString());

                //create a new paragraph
                TextParagraph paragraph = new TextParagraph();

                //apend the text range
                paragraph.TextRanges.Append(textRange);

                //set the alignment
                paragraph.Alignment = textAlign;

                //append to shape

                shape.TextFrame.Paragraphs.Append(paragraph);
            }


            //set the font and fill style
            foreach (TextParagraph paragraph in shape.TextFrame.Paragraphs)
            {
                paragraph.TextRanges[0].LatinFont = new TextFont("Arial Black");
                paragraph.TextRanges[0].Fill.FillType = FillFormatType.Solid;
                paragraph.TextRanges[0].Fill.SolidColor.Color = Color.Black;
            }

            //save the document
            presentation.SaveToFile("alignment.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("alignment.pptx");
        }
    }
}
[VB.NET]
Imports System.Text
Imports System.Drawing
Imports Spire.Presentation
Imports Spire.Presentation.Drawing

Public Class Form1

    Private Sub btnRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRun.Click

        '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

        'append new shape
        Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(50, 70, 350, 200))
        shape.TextFrame.Paragraphs(0).Alignment = TextAlignmentType.Left
        shape.Fill.FillType = FillFormatType.None
        shape.TextFrame.Text = "Demo about Alignment"

        For Each textAlign As TextAlignmentType In [Enum].GetValues(GetType(TextAlignmentType))
            'create a text range
            Dim textRange As New TextRange(textAlign.ToString())

            'create a new paragraph
            Dim paragraph As New TextParagraph()

            'apend the text range
            paragraph.TextRanges.Append(textRange)

            'set the alignment
            paragraph.Alignment = textAlign

            'append to shape
            shape.TextFrame.Paragraphs.Append(paragraph)
        Next


        'set the font and fill style
        For Each paragraph As TextParagraph In shape.TextFrame.Paragraphs
            paragraph.TextRanges(0).LatinFont = New TextFont("Arial Black")
            paragraph.TextRanges(0).Fill.FillType = FillFormatType.Solid
            paragraph.TextRanges(0).Fill.SolidColor.Color = Color.Black
        Next

        'save the document
        presentation.SaveToFile("alignment.pptx", FileFormat.Pptx2010)
        System.Diagnostics.Process.Start("alignment.pptx")

    End Sub
End Class
Wednesday, 16 April 2014 02:10

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

You may need to convert PowerPoint documents to images for various purposes, such as preventing other users from editing the contents of the PowerPoint documents, generating thumbnails for the PowerPoint documents, or sharing the PowerPoint documents on social media. In this article, you will learn how to convert PowerPoint documents to various image formats in C# and VB.NET 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

Convert PowerPoint Documents to JPG or PNG Images in C# and VB.NET

The following are the main steps to convert a PowerPoint document to JPG or PNG image:

  • Initialize an instance of Presentation class.
  • Load a PowerPoint document using Presentation.LoadFromFile() method.
  • Iterate through all slides in the PowerPoint document.
  • Save each slide as System.Drawing.Image object using ISlide.SaveAsImage() method.
  • Save the image object to PNG or JPG file using Image.Save() method.
  • C#
  • VB.NET
using Spire.Presentation;
using System.Drawing;

namespace ConvertPowerPointToJpgOrPngImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation presentation = new Presentation();
            //Load a PowerPoint document
            presentation.LoadFromFile(@"Sample.pptx");

            int i = 0;
            //Iterate through all slides in the PowerPoint document
            foreach(ISlide slide in presentation.Slides)
            {                 
                //Save each slide as PNG image
                Image image = slide.SaveAsImage();
                string fileName = string.Format("ToImage-img-{0}.png", i);
                image.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
                i++;
            }
        }
    }
}

C#/VB.NET: Convert PowerPoint to Images (PNG, JPG, TIFF, EMF, SVG)

Convert PowerPoint Documents to TIFF Images in C# and VB.NET

The following are the steps to convert a PowerPoint document to TIFF image:

  • Initialize an instance of Presentation class.
  • Load a PowerPoint document using Presentation.LoadFromFile() method.
  • Convert the PowerPoint document to TIFF image using Presentation.SaveToFile(string, FileFormat) method.
  • C#
  • VB.NET
using Spire.Presentation;

namespace ConvertPowerPointToTiffImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation presentation = new Presentation();
            //Load a PowerPoint document
            presentation.LoadFromFile(@"Sample.pptx");

            //Convert the PowerPoint document to TIFF image
            presentation.SaveToFile("toTIFF.tiff", FileFormat.Tiff);
        }
    }
}

C#/VB.NET: Convert PowerPoint to Images (PNG, JPG, TIFF, EMF, SVG)

Convert PowerPoint Documents to EMF Images in C# and VB.NET

The following are the steps to convert a PowerPoint document to EMF image:

  • Initialize an instance of Presentation class.
  • Load a PowerPoint document using Presentation.LoadFromFile() method.
  • Iterate through all slides in the PowerPoint document.
  • Save each slide to EMF image using ISlide.SaveAsEMF() method.
  • C#
  • VB.NET
using Spire.Presentation;

namespace ConvertPowerPointToEmfImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation presentation = new Presentation();
            //Load a PowerPoint document
            presentation.LoadFromFile(@"Sample.pptx");

            int i = 0;
            //Iterate through all slides in the PowerPoint document
            foreach (ISlide slide in presentation.Slides)
            {
                string fileName = string.Format("ToEmf-{0}.emf", i);
                //Save each slide to EMF image
                slide.SaveAsEMF(fileName);
                //Save each slide to EMF image with specified width and height
                //slide.SaveAsEMF(fileName, 1075, 710);
                i++;
            }
        }
    }
}

C#/VB.NET: Convert PowerPoint to Images (PNG, JPG, TIFF, EMF, SVG)

Convert PowerPoint Documents to SVG Images in C# and VB.NET

The following are the steps to convert a PowerPoint document to SVG images:

  • Initialize an instance of Presentation class.
  • Load a PowerPoint document using Presentation.LoadFromFile() method.
  • Convert the PowerPoint document to SVG and save the results into a queue of byte arrays using Presentation.SaveToSVG() method.
  • Iterate through the byte arrays in the queue.
  • At each iteration, remove and return the byte array at the beginning of the queue using Queue.Dequeue() method.
  • Initialize an instance of FileStream class and save the byte array to an SVG file using FileStream.Write() method.
  • C#
  • VB.NET
using Spire.Presentation;
using System.Collections.Generic;
using System.IO;

namespace ConvertPowerPointToSvgImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation presentation = new Presentation();
            //Load a PowerPoint document
            presentation.LoadFromFile(@"Sample.pptx");

            //Convert the PowerPoint document to SVG and save the results into a queue of byte arrays
            Queue svgBytes = presentation.SaveToSVG();
            int count = svgBytes.Count;
            //Iterate through the byte arrays in the queue
            for (int i = 0; i < count; i++)
            {
                //Remove and return the byte array at the beginning of the queue
                byte[] bt = svgBytes.Dequeue();
                //Specify the output file name
                string fileName = string.Format("ToSVG-{0}.svg", i);
                //Create a FileStream instance
                FileStream fs = new FileStream(fileName, FileMode.Create);
                //Save the byte array to a SVG file
                fs.Write(bt, 0, bt.Length);
            }
        }
    }
}

C#/VB.NET: Convert PowerPoint to Images (PNG, JPG, TIFF, EMF, SVG)

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.

Monday, 14 April 2014 03:23

How to add Controls to Toolbox in WPF

In this document, I will introduce you how to add Spire.PDFViewer controls to Toolbox for WPF application.

How To

Right-click on the blank part of the Toolbox - "Add Tab" - name the new Tab "Spire WPF Controls":

How to add Controls to Toolbox

Right-click on the blank part below "Spire WPF Controls" - "Choose Items" - "WPF Components" - "Browse" to the "Bin" folder - find the file "Spire.PdfViewer.Wpf.dll" - "Open".

How to add Controls to Toolbox

Click "OK". Then you have added controls to Toolbox successfully.

How to add Controls to Toolbox

Monday, 14 April 2014 03:09

How to add Controls to Toolbox in C#

There are three ways to add Spire.PDFViewer controls to Toolbox for Windows Forms application.

In this document, these ways are introduced.

The First Solution

Set the CheckBox below to the CheckState "Checked" during installing Spire.PDFViewer.

How to add Controls to Toolbox

After installment is completed, controls will be added to the Toolbox.

The Second Solution

If you have already installed Spire.PDFViewer, you can also add controls this way:

"Start" -"Programs" -"e-iceblue" -"Spire.PDFViewer" : Click "Add Controls into VS Toolbox".

How to add Controls to Toolbox

Click "Add" to add controls.

How to add Controls to Toolbox

The Third Solution

Right-click on the blank part of the Toolbox - "Add Tab" - name the new Tab "Spire Controls" :

How to add Controls to Toolbox

Right-click on the blank part below "Spire Controls" - "Choose Items" - ".NET Framework Components" - "Browse" to the "Bin" folder – find the file "Spire.PdfViewer.Forms.dll"- "Open".

How to add Controls to Toolbox

Click “OK”. Then you have added controls to Toolbox successfully.

How to add Controls to Toolbox

Monday, 14 April 2014 02:46

How to add Controls to Toolbox in C#

In this document, I will introduce you how to add Spire.DataExport controls to Toolbox for Windows Forms application.

How To

If you have already installed Spire.DataExport, you can add controls this way:

"Start" - "Programs" - "e-iceblue" - "Spire.DataExport" : Click "Add Controls into VS Toolbox".

How to add Controls to Toolbox

Click "Add" to add controls.

How to add Controls to Toolbox

How To

Right-click on the blank part of the Toolbo - "Add Tab" - name the new Tab "Spire Controls":

How to add Controls to Toolbox

Right-click on the blank part below "Spire Controls"- "Choose Items" - ".NET Framework Components" - "Browse” to the "Bin" folde - find the file "Spire.DataExport.dll" -"Open".

How to add Controls to Toolbox

Click "OK". Then you have added controls to Toolbox successfully.

How to add Controls to Toolbox

Monday, 14 April 2014 02:32

How to add Controls to Toolbox in WPF

In this document, I will introduce you how to add Spire.DocViewer controls to Toolbox for WPF application.

How To

Right-click on the blank part of the Toolbox - "Add Tab" - name the new Tab "Spire WPF Controls":

How to add Controls to Toolbox

Right-click on the blank part below "Spire WPF Controls" - "Choose Items" - "WPF Components" - "Browse" to the "Bin" folder - find the file "Spire.DocViewer.Wpf.dll" - "Open".

How to add Controls to Toolbox

Click "OK". Then you have added controls to Toolbox successfully.

How to add Controls to Toolbox

Friday, 11 April 2014 01:54

How to add Controls to Toolbox in C#

There are three ways to add Spire.DocViewer controls to Toolbox for Windows Forms application.

In this document, these ways are introduced. Hoping this document can be helpful to you.

The First Solution

Set the CheckBox below to the CheckState "Checked" during installing Spire.DocViewer.

How to add Controls to Toolbox

After installment is completed, controls will be added to the Toolbox.

The Second Solution

If you have already installed Spire.DocViewer, you can also add controls this way:

"Start" - "Programs" - "e-iceblue" - "Spire.DocViewer" : Click "Add Controls into VS Toolbox".

How to add Controls to Toolbox

Click "Add" to add controls.

How to add Controls to Toolbox

The Third Solution

Right-click on the blank part of the Toolbox - "Add Tab" - name the new Tab "Spire Controls":

How to add Controls to Toolbox

Right-click on the blank part below "Spire Controls" - "Choose Items" - ".NET Framework Components" - "Browse" to the "Bin" folder - find the file "Spire.DocViewer.Forms.dll" - "Open"

How to add Controls to Toolbox

Click "OK". Then you have added controls to Toolbox successfully.

How to add Controls to Toolbox

Wednesday, 09 April 2014 08:51

Extract and Update link from a PDF file

Spire.PDF for .NET is a PDF library which enables users to handle the whole PDF document with wide range of tasks in C#, VB.NET. Spire.PDF supports to create PDF links, extract PDF links, update PDF links and remove PDF links from a PDF file. This article mainly shows how to extract and update link from a PDF file in C#.

Before the steps and codes, please check the original PDF file at first:

PDF link

Firstly we need to create a new Document object and load a PDF file which needs to extract and update the links. The links are represented as annotations in a PDF file. Before extract and update the link from a PDF file, we need to extract all the AnnotationsWidget objects.

The following code snippet shows you how to extract links from the PDF file.

//Load an existing PDF file
PdfDocument document = new PdfDocument();
document.LoadFromFile(@"..\..\output.pdf");

//Get the first page
PdfPageBase page = document.Pages[0];

//Get the annotation collection
PdfAnnotationCollection widgetCollection = page.AnnotationsWidget;

//Verify whether widgetCollection is not null or not
if (widgetCollection.Count > 0)
            {
                foreach (var obj in widgetCollection)
                {

//Get the TextWebLink Annotation
if (obj is PdfTextWebLinkAnnotationWidget)
   {
     PdfTextWebLinkAnnotationWidget link = obj as PdfTextWebLinkAnnotationWidget;

The following code snippet shows you how to update the link in PDF file

//Change the url of TextWebLink Annotation
link.Url = "http://www.e-iceblue.com/Introduce/pdf-for-net-introduce.html";

//Saves PDF document to file.
document.SaveToFile("sample.pdf");

This picture will show you the link has been updated in the PDF file.

Update link

Thursday, 03 April 2014 09:18

Delete bookmark from the PDF document in C#

PDF Bookmarks is widely used to help us locate and link to points that we want to go. Spire.PDF for .NET, a powerful PDF component, not only enables developers to add bookmarks, get bookmark information, but also helps us to remove the bookmarks that we want. This article will show you how to delete bookmark from the PDF document in C# easily.

First, check the PDF document with bookmarks.

Bookmark

Here comes to the steps of how to remove the bookmarks in C#.

  • Download Spire.PDF for .NET and install it correctly. The Spire.PDF installation is clean, professional and wrapped up in a MSI installer.
  • Add Spire.Pdf.dll as reference in the downloaded Bin folder though the below path: "..\Spire.Pdf\Bin\NET4.0\ Spire.Pdf.dll".
  • Check the code snippet of how to delete the bookmarks. With Spire.PDF.NET, we can remove both the particular bookmark and remove all the bookmarks at one time.
using Spire.Pdf;

namespace DeletePDFBookmark
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a new PDF document and load from the file.
            PdfDocument document = new PdfDocument();
            document.LoadFromFile(@"D:\Bookmark.pdf");

            //remove the first bookmark
            document.Bookmarks.RemoveAt(0);

            //remove all bookmarks
            document.Bookmarks.Clear();

            //save the document to file.
            document.SaveToFile("result.pdf");
        }
    }
}

Please check the effective screenshots:

Remove particular bookmark

Remove all Bookmarks