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.

Screenshot
PowerPoint Library for C# / VB.NET Screenshot

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

using System;
using System.IO;
using System.Text;
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();

        string pathToResources = "Resources";

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

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

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

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

        TextRun 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.pdf");
    }
}
Imports System.IO
Imports System.Text
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

        Dim pathToResources As String = "Resources"

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

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

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

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

        Dim run As TextRun = 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.pdf")

    End Sub

End Module