Private Fonts

GemBox.Spreadsheet enables you to specify the location where it should look for font files when saving a spreadsheet to PDF, XPS or image file formats, printing a spreadsheet, 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.Spreadsheet can use file system operations to retrieve font data even in Medium Trust environment.

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

Font file: Almonte Snow.ttf.

Screenshot of PDF with private font created with GemBox.Spreadsheet
PDF with private font created with GemBox.Spreadsheet
using GemBox.Spreadsheet;

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

        var workbook = new ExcelFile();
        var worksheet = workbook.Worksheets.Add("Private Fonts");

        // Current directory contains a font file.
        FontSettings.FontsBaseDirectory = ".";

        worksheet.Parent.Styles.Normal.Font.Name = "Almonte Snow";
        worksheet.Cells[0, 0].Value = "Hello World!";

        workbook.Save("Private Fonts.pdf");
    }
}
Imports GemBox.Spreadsheet

Module Program

    Sub Main()

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

        Dim workbook = New ExcelFile
        Dim worksheet = workbook.Worksheets.Add("Private Fonts")

        ' Current directory contains a font file.
        FontSettings.FontsBaseDirectory = "."

        worksheet.Parent.Styles.Normal.Font.Name = "Almonte Snow"
        worksheet.Cells(0, 0).Value = "Hello World!"

        workbook.Save("Private Fonts.pdf")
    End Sub
End Module

Check next example or download examples from GitHub.