Click or drag to resize

FontSettings Class

Contains font related settings which are used when printing, importing or exporting a document to a file format that requires font information.
Inheritance Hierarchy
SystemObject
  SautinSoft.DocumentFontSettings

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.7.18
Syntax
public static class FontSettings

The FontSettings type exposes the following members.

Properties
 NameDescription
Public propertyStatic memberCommonFontsForLanguages The array of lists with Chinese, Japanese, Korean, Devanagari and other fonts to render characters in this language. You may add any extra fonts intalled at your machine. Use WrittingLanguages to refer to desired font collection.
Public propertyStatic memberMissingFonts Get fonts which were not found during the loading/saving of the current document. Check this property after launching the method Save().
Public propertyStatic memberUserFontsDirectory Gets and sets an extra folder to search fonts (*.ttf, *.otf, *.ttc). Default value: null.
Top
Methods
 NameDescription
Public methodStatic memberCode exampleAddFontSubstitutes Adds substitute (alternative) font names for given original font name.
Public methodStatic memberGetFontSubstitutes Gets array containing alternative font names to be used if original font is not presented in system.
Top
Example

See Developer Guide: Load a PDF and get missing fonts

Load a PDF and get missing fonts using C#
using System;
using System.IO;
using SautinSoft.Document;

namespace Example
{
    class Program
    {

        static void Main(string[] args)
        {
            // Get your free 100-day key here:   
            // https://sautinsoft.com/start-for-free/

            LoadPDF();
        }

        /// <summary>
        /// Load a PDF document and get missing fonts.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/load-pdf-document-get-missing-fonts-net-csharp-vb.php
        /// </remarks>
        static void LoadPDF()
        {            
            string inpFile = @"..\..\..\fonts.pdf";
            string outFile = "Result.docx";

            // Some PDF documents can use rare fonts which isn't installed in your system.
            // During the loading of a PDF document the component tries to find all necessary 
            // fonts installed in your system.
            // In case of the font is missing, you can find its name in the property 'MissingFonts' (after the loading process).
            DocumentCore dc = DocumentCore.Load(inpFile);

            if (SautinSoft.Document.FontSettings.MissingFonts.Count > 0)
            {
                Console.WriteLine("Missing Fonts:");
                foreach (string fontFamily in SautinSoft.Document.FontSettings.MissingFonts)
                    Console.WriteLine(fontFamily);
            }

            // Next, knowing missing fonts, you can install these fonts in your system.

            // Also, you can specify an extra folder where component should find fonts.
            SautinSoft.Document.FontSettings.UserFontsDirectory = @"d:\My Fonts";

            // Furthermore, you can add font substitutes, to use alternative fonts.            
            SautinSoft.Document.FontSettings.AddFontSubstitutes("Melvetika", "Segoe UI");
            Console.WriteLine("We\'ve changed Melvetica font to Segoe UI");

            // Load the document again.
            dc = DocumentCore.Load(inpFile);
            dc.Save(outFile);

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile) { UseShellExecute = true });
            Console.ReadKey();
        }
    }
}
Load a PDF and get missing fonts using VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document

Namespace Example
    Friend Class Program

        Shared Sub Main(ByVal args() As String)
            LoadPDF()
        End Sub
                ''' Get your free 100-day key here:   
                ''' https://sautinsoft.com/start-for-free/
        ''' <summary>
        ''' Load a PDF document and get missing fonts.
        ''' </summary>
        ''' <remarks>
        ''' Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/load-pdf-document-get-missing-fonts-net-csharp-vb.php
        ''' </remarks>
        Private Shared Sub LoadPDF()
            Dim inpFile As String = "..\..\..\fonts.pdf"
            Dim outFile As String = "Result.docx"

            ' Some PDF documents can use rare fonts which isn't installed in your system.
            ' During the loading of a PDF document the component tries to find all necessary 
            ' fonts installed in your system.
            ' In case of the font is missing, you can find its name in the property 'MissingFonts' (after the loading process).
            Dim dc As DocumentCore = DocumentCore.Load(inpFile)

            If SautinSoft.Document.FontSettings.MissingFonts.Count > 0 Then
                Console.WriteLine("Missing Fonts:")
                For Each fontFamily As String In SautinSoft.Document.FontSettings.MissingFonts
                    Console.WriteLine(fontFamily)
                Next fontFamily
            End If

            ' Next, knowing missing fonts, you can install these fonts in your system.

            ' Also, you can specify an extra folder where component should find fonts.
            SautinSoft.Document.FontSettings.UserFontsDirectory = "d:\My Fonts"

            ' Furthermore, you can add font substitutes, to use alternative fonts.            
            SautinSoft.Document.FontSettings.AddFontSubstitutes("Melvetika", "Segoe UI")
            Console.WriteLine("We've changed Melvetica font to Segoe UI")

            ' Load the document again.
            dc = DocumentCore.Load(inpFile)
            dc.Save(outFile)

            ' Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outFile) With {.UseShellExecute = True})
            Console.ReadKey()
        End Sub
    End Class
End Namespace
See Also