News Category

Paragraph and Text

Paragraph and Text (22)

To emphasize some words or phrases in a sentence, most probably you will set different formats such as font type, color, and size to these parts. When we programmatically insert a sentence with various kinds of font styles into a PowerPoint slide, it is an easy task if we format the text at the first place and then append the text to a paragraph. In this article, we attach more importance to introduce how to mix font styles within a single TextRange on an existing PowerPoint slide.

Test File:

As is shown in test file, all words in this TextRange are in the same font style. Now we would like to make some changes.

How to Mix Font Styles within a Single TextRange in C#, VB.NET

Code Snippet:

Step 1: Create a new PowerPoint document and load the test file.

Presentation ppt = new Presentation("Sample.pptx", FileFormat.Pptx2010);

Step 2: Get the shape from PowerPoint slide, get the text from shape and save to a new string variable.

IAutoShape shape = ppt.Slides[0].Shapes[0] as IAutoShape;
string originalText = shape.TextFrame.Text;

Step 3: Split the string by specified words and return substrings to a string array.

string[] splitArray = originalText.Split(new string[] { "bold", "red","underlined","bigger font size" }, StringSplitOptions.None);

Step 4: Remove the paragraph from TextRange.

TextParagraph tp = shape.TextFrame.TextRange.Paragraph;
tp.TextRanges.Clear();

Step 5: Append normal text that is in front of ‘bold’ to the paragraph.

TextRange tr = new TextRange(splitArray[0]);
tp.TextRanges.Append(tr);

Step 6: Set font style of the text ‘bold’ as bold, and append it to the paragraph.

tr = new TextRange("bold");
tr.IsBold = TriState.True;
tp.TextRanges.Append(tr);

Step 7: Repeat step 5 and step 6 to append the rest normal texts and formatted texts to the paragraph.

//normal text
tr = new TextRange(splitArray[1]);
tp.TextRanges.Append(tr);
//red text
tr = new TextRange("red");
tr.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
tr.Format.Fill.SolidColor.Color = Color.Red;
tp.TextRanges.Append(tr);
//normal text
tr = new TextRange(splitArray[2]);
tp.TextRanges.Append(tr);
//underline text
tr = new TextRange("underlined");
tr.TextUnderlineType = TextUnderlineType.Single;
tp.TextRanges.Append(tr);
//normal text
tr = new TextRange(splitArray[3]);
tp.TextRanges.Append(tr);
//bigger size text
tr = new TextRange("bigger font size");
tr.FontHeight = 35;
tp.TextRanges.Append(tr);
//normal text
tr = new TextRange(splitArray[4]);
tp.TextRanges.Append(tr);

Step 8: Save the file.

ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);

Output:

How to Mix Font Styles within a Single TextRange in C#, VB.NET

Full Code:

[C#]
using Spire.Presentation;
using System;
using System.Drawing;
namespace MixFontStyle
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation ppt = new Presentation("Sample.pptx", FileFormat.Pptx2010);
            IAutoShape shape = ppt.Slides[0].Shapes[0] as IAutoShape;
            string originalText = shape.TextFrame.Text;
            string[] splitArray = originalText.Split(new string[] { "bold", "red", "underlined", "bigger font size" }, StringSplitOptions.None);
            TextParagraph tp = shape.TextFrame.TextRange.Paragraph;
            tp.TextRanges.Clear();
            //normal text
            TextRange tr = new TextRange(splitArray[0]);
            tp.TextRanges.Append(tr);
            //bold text
            tr = new TextRange("bold");
            tr.IsBold = TriState.True;
            tp.TextRanges.Append(tr);
            //normal text
            tr = new TextRange(splitArray[1]);
            tp.TextRanges.Append(tr);
            //red text
            tr = new TextRange("red");
            tr.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
            tr.Format.Fill.SolidColor.Color = Color.Red;
            tp.TextRanges.Append(tr);
            //normal text
            tr = new TextRange(splitArray[2]);
            tp.TextRanges.Append(tr);
            //underline text
            tr = new TextRange("underlined");
            tr.TextUnderlineType = TextUnderlineType.Single;
            tp.TextRanges.Append(tr);
            //normal text
            tr = new TextRange(splitArray[3]);
            tp.TextRanges.Append(tr);
            //bigger size text
            tr = new TextRange("bigger font size");
            tr.FontHeight = 35;
            tp.TextRanges.Append(tr);
            //normal text
            tr = new TextRange(splitArray[4]);
            tp.TextRanges.Append(tr);
            ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);

        }
    }
}
[VB.NET]
Imports Spire.Presentation
Imports System.Drawing
Namespace MixFontStyle
	Class Program
		Private Shared Sub Main(args As String())
			Dim ppt As New Presentation("Sample.pptx", FileFormat.Pptx2010)
			Dim shape As IAutoShape = TryCast(ppt.Slides(0).Shapes(0), IAutoShape)
			Dim originalText As String = shape.TextFrame.Text
			Dim splitArray As String() = originalText.Split(New String() {"bold", "red", "underlined", "bigger font size"}, StringSplitOptions.None)
			Dim tp As TextParagraph = shape.TextFrame.TextRange.Paragraph
			tp.TextRanges.Clear()
			'normal text
			Dim tr As New TextRange(splitArray(0))
			tp.TextRanges.Append(tr)
			'bold text
			tr = New TextRange("bold")
			tr.IsBold = TriState.[True]
			tp.TextRanges.Append(tr)
			'normal text
			tr = New TextRange(splitArray(1))
			tp.TextRanges.Append(tr)
			'red text
			tr = New TextRange("red")
			tr.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid
			tr.Format.Fill.SolidColor.Color = Color.Red
			tp.TextRanges.Append(tr)
			'normal text
			tr = New TextRange(splitArray(2))
			tp.TextRanges.Append(tr)
			'underline text
			tr = New TextRange("underlined")
			tr.TextUnderlineType = TextUnderlineType.[Single]
			tp.TextRanges.Append(tr)
			'normal text
			tr = New TextRange(splitArray(3))
			tp.TextRanges.Append(tr)
			'bigger size text
			tr = New TextRange("bigger font size")
			tr.FontHeight = 35
			tp.TextRanges.Append(tr)
			'normal text
			tr = New TextRange(splitArray(4))
			tp.TextRanges.Append(tr)
			ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010)

		End Sub
	End Class
End Namespace

As a powerful and easy to use .NET component, Spire.Presentation enable developers to generate, modify, convert, render, and print documents without installing Microsoft PowerPoint. In this article let's see how to remove textbox.

Make sure Spire.Presentation for .NET has been installed correctly and then add Spire.Presentation.dll as reference in the downloaded Bin folder through the below path, for example .NET 4.0 : "..\Spire.Presentation\Bin\NET4.0\ Spire. Presentation.dll". Here comes to the details of how to remove textbox from PPT files:

Step 1: Create a PPT document and load sample PPT file. In this sample file three textboxes are added by order with their name number.

Presentation ppt = new Presentation("Sample.pptx", FileFormat.Pptx2010);

Remove Textbox from PowerPoint Files

Step 2: Traverse all the shapes in Slide[0], then remove them as long as they were found.

ISlide slide = ppt.Slides[0];

      for (int i = 0; i < slide.Shapes.Count;)
      {
         IAutoShape shape = slide.Shapes[i] as IAutoShape;
          slide.Shapes.Remove(shape);
       }

Step 3: Save the document as "Result.pptx" and review.

ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);
System.Diagnostics.Process.Start("Result.pptx");

The result is just as we thought.

Remove Textbox from PowerPoint Files

If we need to delete textbox1, just remove the first shape. Check if this shape is textbox and its contents is “Textbox1” and then remove it, modify Step2 as:

ISlide slide = ppt.Slides[0];

 for (int i = 0; i < slide.Shapes.Count; )
     {
           IAutoShape shape = slide.Shapes[i] as IAutoShape;
           if (shape.IsTextBox ||shape.TextFrame.Text.Equals("Textbox1"))
            {
              slide.Shapes.Remove(shape);
             }
      }

Here is the result:

Remove Textbox from PowerPoint Files

Full Code:

using Spire.Presentation;
namespace RemoveText
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation ppt = new Presentation("Sample.pptx", FileFormat.Pptx2010);

            ISlide slide = ppt.Slides[0];

            for (int i = 0; i < slide.Shapes.Count; )
            {
                IAutoShape shape = slide.Shapes[0] as IAutoShape;
                slide.Shapes.Remove(shape);
            }

            ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("Result.pptx");
        }
    }
}

Remove Textbox1:

using Spire.Presentation;
namespace RemoveText
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation ppt = new Presentation("Sample.pptx", FileFormat.Pptx2010);

            ISlide slide = ppt.Slides[0];

            for (int i = 0; i < slide.Shapes.Count; )
            {
                IAutoShape shape = slide.Shapes[i] as IAutoShape;
                if (shape.IsTextBox || shape.TextFrame.Text.Equals("Textbox1"))
                {
                    slide.Shapes.Remove(shape);
                }
            }

            ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("Result.pptx");

        }
    }

When sending a PowerPoint document containing a lot of media files and images to others for text proofreading, you may find that the transfer speed is quite slow because of the large file size. In such a case, it is better to extract the text from PowerPoint to MS Word or Notepad first, and then send only the text content. In addition, the extracted text content can also be archived or backed up for future reference. In this article, you will learn how to extract text from a PowerPoint Presentation 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

Extract Text from PowerPoint Presentations in C# and VB.NET

To facilitate the sharing or delivery of text information in a PowerPoint document, text extraction is an operation occasionally required. The following are the steps to extract text from all presentation slides and save in a TXT file.

  • Initialize an instance of the Presentation class.
  • Load a sample PowerPoint document using Presentation.LoadFromFile() method.
  • Create a StringBuilder instance.
  • Iterate through each slide in the document, and then iterate through all the shapes in each slide.
  • Determine whether the shapes are of IAutoShape type. If yes, iterate through all the paragraphs in each shape and get the paragraph text using TextParagraph.Text property.
  • Append the extracted text to the StringBuilder instance using StringBuilder.AppendLine() method
  • Create a new txt file and write the extracted text to the file using File.WriteAllText() method.
  • C#
  • VB.NET
using Spire.Presentation;
using System.IO;
using System.Text;
namespace ExtractText
{
    class Program
    {
        static void Main(string[] args)
        {
            //Initialize an instance of the Presentation class
            Presentation presentation = new Presentation();

            //Load a sample PowerPoint document
            presentation.LoadFromFile("Island.pptx");
            //Create a StringBuilder instance
            StringBuilder sb = new StringBuilder();

            //Iterate through each slide in the document
            foreach (ISlide slide in presentation.Slides)
            {
                //Iterate through each shape in each slide
                foreach (IShape shape in slide.Shapes)
                {
                    //Check if the shape is of IAutoShape type
                    if (shape is IAutoShape)
                    {
                        //Iterate through all paragraphs in each shape
                        foreach (TextParagraph tp in (shape as IAutoShape).TextFrame.Paragraphs)
                        {
                            //Extract text and save to StringBuilder instance
                            sb.AppendLine(tp.Text);
                        }
                    }
                }
            }
            //Create a new txt file to save the extracted text
            File.WriteAllText("ExtractText.txt", sb.ToString());
        }
    }
}

C#/VB.NET: Extract Text from PowerPoint Presentations

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.

PPT file format is a vivid and explicit way to present your stuff. PPT file can be very beautiful and powerful. And text is a basic element that PPT supports. Spire.Presentation is a powerful .NET component specially designed for developers. It enables developers to manipulate PPT files easily and flexibly. In this document, I will introduce you how to add a paragraph to PPT file using Spire.Presentation.

Step 1. Create a PPT document.

Presentation presentation = new Presentation();

Step 2. Add a new shape to the 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;

Shape represents a TextBox in PPT document.

Step 3. Add some text to the shape.

shape.TextFrame.Text = "This powerful component suite contains the most up-to-date versions of all .NET WPF Silverlight components offered by E-iceblue.";

These will form a new paragraph.

Step 4. Set the alignment of the paragraph.

shape.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Left;

Step 5. Set the indent of the paragraph.

shape.TextFrame.Paragraphs[0].Indent = 25*2;

Step 6. Set the line spacing of the paragraph.

shape.TextFrame.Paragraphs[0].LineSpacing = 250;

Step 7. Save the document.

presentation.SaveToFile("para.pptx", FileFormat.Pptx2010);

Full code:

[C#]
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace AddParagh
{
    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;

            //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;

            //set the alignment
            shape.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Left;
            //set the indent
            shape.TextFrame.Paragraphs[0].Indent = 50;
            //set the linespacing
            shape.TextFrame.Paragraphs[0].LineSpacing = 150;
            shape.TextFrame.Text = "This powerful component suite contains the most up-to-date versions of all .NET WPF Silverlight components offered by E-iceblue.";

            //set the Font
            shape.TextFrame.Paragraphs[0].TextRanges[0].LatinFont = new TextFont("Arial Rounded MT Bold");
            shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = FillFormatType.Solid;
            shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.Black;

            //save the document
            presentation.SaveToFile("para.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("para.pptx");
        }
    }
}
[VB.NET]
'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, 450, 150))
shape.Fill.FillType = FillFormatType.None
shape.ShapeStyle.LineColor.Color = Color.White

'set the alignment
shape.TextFrame.Paragraphs(0).Alignment = TextAlignmentType.Left
'set the indent
shape.TextFrame.Paragraphs(0).Indent = 50
'set the linespacing
shape.TextFrame.Paragraphs(0).LineSpacing = 150
shape.TextFrame.Text = "This powerful component suite contains the most up-to-date versions of all .NET WPF Silverlight components offered by E-iceblue."

'set the Font
shape.TextFrame.Paragraphs(0).TextRanges(0).LatinFont = New TextFont("Arial Rounded MT Bold")
shape.TextFrame.Paragraphs(0).TextRanges(0).Fill.FillType = FillFormatType.Solid
shape.TextFrame.Paragraphs(0).TextRanges(0).Fill.SolidColor.Color = Color.Black

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

Screenshot:

Add a Paragraph to PPT file

Lists are a powerful tool in PowerPoint presentations that enable you to organize and present information in a clear and concise manner. Whether you're showcasing key points, summarizing ideas, or highlighting important details, utilizing lists can enhance the visual appeal, readability and professionalism of your slides. In this article, we will explore how to create numbered lists and bulleted lists in PowerPoint presentations 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

Create a Numbered List in PowerPoint in C# and VB.NET

A numbered list in PowerPoint is a list of items where each item is preceded by a number or a sequence of numbers. It follows a sequential order, typically starting from 1 and progressing incrementally. Numbered lists are commonly used to present steps, instructions, rankings, or any information that requires a specific order.

To create a numbered list in a PowerPoint presentation using Spire.Presentation for .NET, you can follow these steps:

  • Create a Presentation object.
  • Get the first slide using Presentation.Slides[0] property.
  • Append a shape to the slide using ISlide.Shapes.AppendShape() method and set the shape style.
  • Specify the items of the list inside a String array.
  • Create paragraphs based on the list items, and set the bullet type of these paragraphs to Numbered using ParagraphProperties.BulletType property.
  • Set the numbered bullet style of these paragraphs using ParagraphProperties.BulletStyle property.
  • Add these paragraphs to the shape using IAutoShape.TextFrame.Paragraphs.Append() method.
  • Save the document to a PowerPoint file using Presentation.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;

namespace CreateNumberedList
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation object
            Presentation presentation = new Presentation();
            //Get the first slide
            ISlide slide = presentation.Slides[0];

            //Add a shape to the slide and set the shape style
            IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 300, 200));
            shape.Fill.FillType = FillFormatType.None;
            shape.Line.FillType= FillFormatType.None;

            //Add text to the default paragraph
            TextParagraph paragraph = shape.TextFrame.Paragraphs[0];
            paragraph.Text = "Required Web Development Skills:";
            paragraph.Alignment = TextAlignmentType.Left;
            paragraph.TextRanges[0].Fill.FillType = FillFormatType.Solid;
            paragraph.TextRanges[0].Fill.SolidColor.Color = Color.Black;

            //Specify the list items
            string[] listItems = new string[] {
                " Command-line Unix",
                " Vim",
                " HTML",
                " CSS",
                " Python",
                " JavaScript",
                " SQL"
            };

            //Create a numbered list
            foreach (string item in listItems)
            {
                TextParagraph textParagraph = new TextParagraph();
                textParagraph.Text = item;
                textParagraph.Alignment = TextAlignmentType.Left;
                textParagraph.TextRanges[0].Fill.FillType = FillFormatType.Solid;
                textParagraph.TextRanges[0].Fill.SolidColor.Color = Color.Black;

                textParagraph.BulletType = TextBulletType.Numbered;
                textParagraph.BulletStyle = NumberedBulletStyle.BulletArabicPeriod;
                shape.TextFrame.Paragraphs.Append(textParagraph);
            }

            //Save the result document
            presentation.SaveToFile("NumberedList.pptx", FileFormat.Pptx2013);
        }
    }
}

C#/VB.NET: Create Numbered or Bulleted Lists in PowerPoint

Create a Symbol Bulleted List in PowerPoint in C# and VB.NET

A symbol bulleted list in PowerPoint uses symbols instead of numbers to visually represent each item. Symbol bulleted lists are useful for presenting non-sequential information or a collection of points without a specific order.

To create a symbol bulleted list in a PowerPoint presentation using Spire.Presentation for .NET, you can follow these steps:

  • Create a Presentation object.
  • Get the first slide using Presentation.Slides[0] property.
  • Append a shape to the slide using ISlide.Shapes.AppendShape() method and set the shape style.
  • Specify the items of the list inside a String array.
  • Create paragraphs based on the list items, and set the bullet type of these paragraphs to Symbol using ParagraphProperties.BulletType property.
  • Add these paragraphs to the shape using IAutoShape.TextFrame.Paragraphs.Append() method.
  • Save the document to a PowerPoint file using Presentation.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;

namespace CreateSymbolBulletedList
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation object
            Presentation presentation = new Presentation();
            //Get the first slide
            ISlide slide = presentation.Slides[0];

            //Add a shape to the slide and set the shape style
            IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 350, 200));
            shape.Fill.FillType = FillFormatType.None;
            shape.Line.FillType = FillFormatType.None;

            //Add text to the default paragraph
            TextParagraph paragraph = shape.TextFrame.Paragraphs[0];
            paragraph.Text = "Computer Science Subjects:";
            paragraph.Alignment = TextAlignmentType.Left;
            paragraph.TextRanges[0].Fill.FillType = FillFormatType.Solid;
            paragraph.TextRanges[0].Fill.SolidColor.Color = Color.Black;

            //Specify the list items
            string[] listItems = new string[] {
                " Data Structure",
                " Algorithm",
                " Computer Networks",
                " Operating System",
                " Theory of Computations",
                " C Programming",
                " Computer Organization and Architecture"
            };

            //Create a symbol bulleted list
            foreach (string item in listItems)
            {
                TextParagraph textParagraph = new TextParagraph();
                textParagraph.Text = item;
                textParagraph.Alignment = TextAlignmentType.Left;
                textParagraph.TextRanges[0].Fill.FillType = FillFormatType.Solid;
                textParagraph.TextRanges[0].Fill.SolidColor.Color = Color.Black;
                textParagraph.BulletType = TextBulletType.Symbol;
                shape.TextFrame.Paragraphs.Append(textParagraph);
            }

            //Save the result document
            presentation.SaveToFile("SymbolBulletedList.pptx", FileFormat.Pptx2013);
        }
    }
}

C#/VB.NET: Create Numbered or Bulleted Lists in PowerPoint

Create an Image Bulleted List in PowerPoint in C# and VB.NET

An image bulleted list in PowerPoint replaces the traditional bullet points with small images or icons. Instead of using numbers or symbols, each item is represented by an image that adds a visual element to the list. Image bulleted lists are commonly used when you want to incorporate visual cues or represent items with relevant icons or graphics.

To create an image bulleted list in a PowerPoint presentation using Spire.Presentation for .NET, you can follow these steps:

  • Create a Presentation object.
  • Get the first slide using Presentation.Slides[0] property.
  • Append a shape to the slide using ISlide.Shapes.AppendShape() method and set the shape style.
  • Specify the items of the list inside a String array.
  • Create paragraphs based on the list items, and set the bullet type of these paragraphs to Picture using ParagraphProperties.BulletType property.
  • Set the image that will be used as bullets using ParagraphProperties.BulletPicture.EmbedImage property.
  • Add these paragraphs to the shape using IAutoShape.TextFrame.Paragraphs.Append() method.
  • Save the document to a PowerPoint file using Presentation.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;

namespace CreateImageBulletedList
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation object
            Presentation presentation = new Presentation();
            //Get the first slide
            ISlide slide = presentation.Slides[0];

            //Add a shape to the slide and set the shape style
            IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 400, 180));
            shape.Fill.FillType = FillFormatType.None;
            shape.Line.FillType = FillFormatType.None;

            //Add text to the default paragraph
            TextParagraph paragraph = shape.TextFrame.Paragraphs[0];
            paragraph.Text = "Project Task To-Do List:";
            paragraph.Alignment = TextAlignmentType.Left;
            paragraph.TextRanges[0].Fill.FillType = FillFormatType.Solid;
            paragraph.TextRanges[0].Fill.SolidColor.Color = Color.Black;

            //Specify the list items
            string[] listItems = new string[] {
                " Define projects and tasks you're working on",
                " Assign people to tasks",
                " Define the priority levels of your tasks",
                " Keep track of the progress status of your tasks",
                " Mark tasks as done when completed"
            };

            //Create an image bulleted list
            foreach (string item in listItems)
            {
                TextParagraph textParagraph = new TextParagraph();
                textParagraph.Text = item;
                textParagraph.Alignment = TextAlignmentType.Left;
                textParagraph.TextRanges[0].Fill.FillType = FillFormatType.Solid;
                textParagraph.TextRanges[0].Fill.SolidColor.Color = Color.Black;
                textParagraph.BulletType = TextBulletType.Picture;
                IImageData image = presentation.Images.Append(Image.FromFile("icon.png"));
                textParagraph.BulletPicture.EmbedImage = image;
                shape.TextFrame.Paragraphs.Append(textParagraph);
            }

            //Save the result document
            presentation.SaveToFile("ImageBulletedList.pptx", FileFormat.Pptx2013);
        }
    }
}

C#/VB.NET: Create Numbered or Bulleted Lists in PowerPoint

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.

Suppose you want your doc document more attract and prominent your content. You would use a kind of border and shading style to beatify your document and give prominence to the key points. AS well as doc document the PPT document also can set shape to as border and shading.

Spire.Presentation for .NET, a professional .NET PPT component to allow users to manipulate PPT documents without automation. It can set kinds of shape types which can help users to beatify their document as their expectation

Below demonstrate the effect by a screenshot which shows a shape type in PPT document with C#, VB.NET via Spire.Presentation for .NET.

Set border and shading in PPT document

There is a guide to introduce a method to set shape type to achieve above screenshot with C#, VB.NET via Spire.Presentation for .NET.

This method is:

First, new a PPT document and set its slide. Then, new a shape and set its line color and gradient color. Last set the font and fill style for the paragraph. Now Download and install Spire.Presentation for .NET and use below code to experience this method to set shape type in PPT document.

The full code:

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

namespace BorderAndShading
{
    class Program
    {
        static void Main(string[] args)
        {
            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(120, 70, 450, 300));

            //set the LineColor
            shape.ShapeStyle.LineColor.Color = Color.Green;

            //set the gradient color of shape
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Gradient;
            shape.Fill.Gradient.GradientShape = Spire.Presentation.Drawing.GradientShapeType.Rectangle;
            shape.Fill.Gradient.GradientStyle = Spire.Presentation.Drawing.GradientStyle.FromCorner1;
            shape.Fill.Gradient.GradientStops.Append(1f, KnownColors.GreenYellow);
            shape.Fill.Gradient.GradientStops.Append(0, KnownColors.PowderBlue);
            shape.AppendTextFrame("Borders and Shading");

            //set the Font
            shape.TextFrame.Paragraphs[0].TextRanges[0].LatinFont = new TextFont("Arial Black");
            shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = FillFormatType.Solid;
            shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.Black;

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

Module Module1

    Sub Main()
        '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(30, 70, 550, 300))

        'set the LineColor
        shape.ShapeStyle.LineColor.Color = Color.Green

        'set the gradient color of shape
        shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Gradient
        shape.Fill.Gradient.GradientShape = Spire.Presentation.Drawing.GradientShapeType.Rectangle
        shape.Fill.Gradient.GradientStyle = Spire.Presentation.Drawing.GradientStyle.FromCorner1
        shape.Fill.Gradient.GradientStops.Append(1.0F, KnownColors.GreenYellow)

        shape.Fill.Gradient.GradientStops.Append(0, KnownColors.PowderBlue)
        shape.AppendTextFrame("Borders and Shading")

        'set the Font
        shape.TextFrame.Paragraphs(0).TextRanges(0).LatinFont = New TextFont("Arial Black")
        shape.TextFrame.Paragraphs(0).TextRanges(0).Fill.FillType = FillFormatType.Solid
        shape.TextFrame.Paragraphs(0).TextRanges(0).Fill.SolidColor.Color = Color.Black

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

    End Sub

End Module

PPT file format is commonly used for office and educational slide shows. With Spire.Presentation, you can generate beautiful and powerful PPT files and edit them without utilizing Microsoft PowerPoint. The PPT files generated are compatible with PowerPoint.

In this document, I will introduce you how to set Font of text in PPT file. First add IAutoShape to the slide. The IAutoShape is a TextBox. You have to add it first. Then add text to the IAutoShape using the method AppendTextFrame. Then you can get the property TextRange of the shape. Using TextRange, you can set Font of text finally.

Step 1: Add the shape to the slide.

IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle,
                new RectangleF(50, 70, 400, 50));

Step 2: Add the text to the shape.

shape.AppendTextFrame("This is a demo of text font and color.");

Step 3: Get the property TextRange of the text.

TextRange textRange = shape.TextFrame.TextRange;

Step 4: Set the Font of the text in shape.

textRange.FontHeight = 21;
textRange.IsItalic = TriState.True;
textRange.TextUnderlineType = TextUnderlineType.Single;
textRange.LatinFont = new TextFont("Gulim");

Step 5: Save the document.

presentation.SaveToFile("text.pptx", FileFormat.Pptx2007);

Full code:

using Spire.Presentation;
using System.Drawing;
namespace SetFont
{
    class Program
    {
        static void Main(string[] args)
        {
            //create PPT document
            Presentation presentation = new Presentation();

            //set background Image
            string ImageFile = @"..\..\..\..\..\..\Data\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, 400, 50));

            //set the LineColor
            shape.ShapeStyle.LineColor.Color = Color.Black;

            //set the color and fill style
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
            shape.Fill.SolidColor.Color = Color.LightGray;
            shape.AppendTextFrame("This is a demo of text font and color.");

            //set the color of text in shape
            TextRange textRange = shape.TextFrame.TextRange;
            textRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
            textRange.Fill.SolidColor.Color = Color.Green;

            //set the Font of text in shape
            textRange.FontHeight = 21;
            textRange.IsItalic = TriState.True;
            textRange.TextUnderlineType = TextUnderlineType.Single;
            textRange.LatinFont = new TextFont("Gulim");

            //save the document
            presentation.SaveToFile("text.pptx", FileFormat.Pptx2007);
            System.Diagnostics.Process.Start("text.pptx");
        }
    }
}

Screenshot:

How to Set Font of Text in PPT

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
Page 2 of 2