GemBox.Presentation is a .NET component that enables you to read, write, edit, convert, and print presentation files from your .NET applications using one simple API.

Character Formatting

GemBox.Presentation supports a variety of text-formatting options like font name, size and color (fill), underline style and color (fill), on/off properties like bold and italic and many others.

The following example shows some of the available character-formatting options.

Screenshot
Character Formatting Screenshot

See the full code below, use Run Example to execute.

using GemBox.Presentation;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        PresentationDocument presentation = new PresentationDocument();

        // Create new slide.
        Slide slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create new text box.
        TextBox textBox = slide.Content.AddTextBox(
            ShapeGeometryType.RoundedRectangle, 2, 2, 10, 20, LengthUnit.Centimeter);

        // Create new paragraph.
        TextParagraph paragraph = textBox.AddParagraph();

        // Create new run.
        TextRun run = paragraph.AddRun("All caps: ");
        run = paragraph.AddRun("Capital letters");
        run.Format.Caps = CapsType.All;

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Bold: ");
        run = paragraph.AddRun("Bold text");
        run.Format.Bold = true;

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Italic: ");
        run = paragraph.AddRun("Italic text");
        run.Format.Italic = true;

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Underline: ");
        run = paragraph.AddRun("Single underline text");
        run.Format.UnderlineStyle = UnderlineStyle.Single;

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Font size: ");
        run = paragraph.AddRun("Font size is 14 points");
        run.Format.Size = Length.From(14, LengthUnit.Point);

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Strikethrough: ");
        run = paragraph.AddRun("Some text");
        run.Format.Strikethrough = StrikethroughType.Single;

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Double strikethrough: ");
        run = paragraph.AddRun("Some text");
        run.Format.Strikethrough = StrikethroughType.Double;

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Font color: ");
        run = paragraph.AddRun("Red text");
        run.Format.Fill.SetSolid(Color.FromName(ColorName.Red));

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Font name: ");
        run = paragraph.AddRun("Arial Black");
        run.Format.Font = "Arial Black";

        presentation.Save("Character Formatting.pptx");
    }
}
Imports GemBox.Presentation

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim presentation As PresentationDocument = New PresentationDocument

        ' Create New slide.
        Dim slide As Slide = presentation.Slides.AddNew(SlideLayoutType.Custom)

        ' Create New text box.
        Dim textBox As TextBox = slide.Content.AddTextBox(
            ShapeGeometryType.RoundedRectangle, 2, 2, 10, 20, LengthUnit.Centimeter)

        ' Create New paragraph.
        Dim paragraph As TextParagraph = textBox.AddParagraph()

        ' Create New run.
        Dim run As TextRun = paragraph.AddRun("All caps: ")
        run = paragraph.AddRun("Capital letters")
        run.Format.Caps = CapsType.All

        paragraph.AddLineBreak()

        run = paragraph.AddRun("Bold: ")
        run = paragraph.AddRun("Bold text")
        run.Format.Bold = True

        paragraph.AddLineBreak()

        run = paragraph.AddRun("Italic: ")
        run = paragraph.AddRun("Italic text")
        run.Format.Italic = True

        paragraph.AddLineBreak()

        run = paragraph.AddRun("Underline: ")
        run = paragraph.AddRun("Single underline text")
        run.Format.UnderlineStyle = UnderlineStyle.Single

        paragraph.AddLineBreak()

        run = paragraph.AddRun("Font size: ")
        run = paragraph.AddRun("Font size is 14 points")
        run.Format.Size = Length.From(14, LengthUnit.Point)

        paragraph.AddLineBreak()

        run = paragraph.AddRun("Strikethrough: ")
        run = paragraph.AddRun("Some text")
        run.Format.Strikethrough = StrikethroughType.Single

        paragraph.AddLineBreak()

        run = paragraph.AddRun("Double strikethrough: ")
        run = paragraph.AddRun("Some text")
        run.Format.Strikethrough = StrikethroughType.Double

        paragraph.AddLineBreak()

        run = paragraph.AddRun("Font color: ")
        run = paragraph.AddRun("Red text")
        run.Format.Fill.SetSolid(Color.FromName(ColorName.Red))

        paragraph.AddLineBreak()

        run = paragraph.AddRun("Font name: ")
        run = paragraph.AddRun("Arial Black")
        run.Format.Font = "Arial Black"

        presentation.Save("Character Formatting.pptx")

    End Sub

End Module

Check next sample.