Private Fonts

GemBox.Presentation enables you to specify the location where it should look for font files when saving a presentation to PDF, XPS or image file formats, printing a presentation, or converting it to XpsDocument or ImageSource instances as in the following example.

This feature is especially useful for ASP.NET applications working in Medium Trust environment. By specifying a location that is under your ASP.NET application's control, GemBox.Presentation can use file system operations to retrieve font data even in Medium Trust environment.

By default, if location is not specified, GemBox.Presentation will look for font files in default font directory for the operating system.

Font file: Almonte Snow.ttf.

Slide text drawn using private font with GemBox.Presentation
Screenshot of slide text drawn using private font with GemBox.Presentation
using GemBox.Presentation;

class Program
{
    static void Main()
    {
        // If using the Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Sets the base directory path where component looks for fonts.
        FontSettings.FontsBaseDirectory = ".";

        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        var textBox = slide.Content.AddTextBox(
            ShapeGeometryType.Rectangle, 2, 2, 8, 8, LengthUnit.Centimeter);

        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));

        var run = textBox.AddParagraph().AddRun(
            "Shows how to use private fonts with GemBox.Presentation component.");

        run.Format.Font = "Almonte Snow";
        run.Format.Size = Length.From(16, LengthUnit.Point);
        run.Format.Fill.SetSolid(Color.FromName(ColorName.Black));

        presentation.Save("Private Fonts.%OutputFileType%");
    }
}
Imports GemBox.Presentation

Module Program

    Sub Main()

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

        Dim presentation = New PresentationDocument

        ' Sets the base directory path where component looks for fonts.
        FontSettings.FontsBaseDirectory = "."

        Dim slide = presentation.Slides.AddNew(SlideLayoutType.Custom)

        Dim textBox = slide.Content.AddTextBox(
            ShapeGeometryType.Rectangle, 2, 2, 8, 8, LengthUnit.Centimeter)

        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray))

        Dim run = textBox.AddParagraph().AddRun(
            "Shows how to use private fonts with GemBox.Presentation component.")

        run.Format.Font = "Almonte Snow"
        run.Format.Size = Length.From(16, LengthUnit.Point)
        run.Format.Fill.SetSolid(Color.FromName(ColorName.Black))

        presentation.Save("Private Fonts.%OutputFileType%")
    End Sub
End Module

See also


Next steps

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.

Download Buy