Skip to main content

OpenTypeFontCollection

Version: 12.0

cete.dynamicpdf.text.opentypefontcollection

OpenTypeFontCollection​

Represents an OpenType font collection.

public class OpenTypeFontCollection
Public Class OpenTypeFontCollection

Inheritance: Object → OpenTypeFontCollection

Licensing Info​

This class is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Examples​

This example shows how to use the True Type Font Collection(TTC) font file.

Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
Imports ceTe.DynamicPDF.Text

Module MyModule

Sub CreatePDF()

' Create a PDF Document
Dim MyDocument As Document = New Document

' Create a Page and add it to the document
Dim MyPage As Page = New Page
MyDocument.Pages.Add(MyPage)

'Create a TextArea
Dim area As TextArea = New TextArea("Hello TTC Testing", 100, 100, 100, 100)

'Create a open type font collection.
Dim collection As OpenTypeFontCollection = New OpenTypeFontCollection("Path of .ttc file")

'Assign opentype font to label from Collection using the Index
area.Font = collection.GetFont(3)

' Add a label to the page
MyPage.Elements.Add(area)

' Save the PDF document
MyDocument.Draw("C:\MyDocument.pdf")

End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
using ceTe.DynamicPDF.Text;

public class Example
{
public static void CreatePDF(string outputPath, string fontCollectionPath)
{
// Create a PDF Document
Document document = new Document();

// Create a new Page
Page page = new Page();

// Add the page to the document
document.Pages.Add(page);

//Create a TextArea
TextArea area = new TextArea("Hello TTC Testing", 100, 100, 100, 100);
//Create a open type font collection.
OpenTypeFontCollection collection = new OpenTypeFontCollection(fontCollectionPath);
//Assign opentype font to label from Collection using the Index
area.Font = collection.GetFont(3);

// Add label to the page
page.Elements.Add(area);

// Save the PDF document
document.Draw(outputPath);
}
}

Constructors​

OpenTypeFontCollection(Stream)​

Intializes a new instance of OpenTypeFont class.

public OpenTypeFontCollection(Stream stream)
Public Sub New (stream As Stream)

Parameters​

Stream containing the opentype / truetype font data.

Licensing Info​

This constructor is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

OpenTypeFontCollection(String)​

Initializes a new instance of OpenTypeFontCollection class.

public OpenTypeFontCollection(string filePath)
Public Sub New (filePath As String)

Parameters​

Physical file path of the truetype collection file.

Licensing Info​

This constructor is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Methods​

Equals(Object)​

Determines whether the specified Object is equal to the current Object . (Inherited from Object)

public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean

Parameters​

The Object to compare with the current Object .

Returns​

true if the specified Object is equal to the current Object ; otherwise, false.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

GetFont(Int32)​

Gets the font from the Open type collection based on the index.

public OpenTypeFont GetFont(int index)
Function GetFont(index As Integer) As OpenTypeFont

Parameters​

Index of the font in the open type collection.

Returns​

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Examples​

This example shows how to use the GetFont method using Index

Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
Imports ceTe.DynamicPDF.Text

Module MyModule

Sub CreatePDF()

' Create a PDF Document
Dim MyDocument As Document = New Document

' Create a Page and add it to the document
Dim MyPage As Page = New Page
MyDocument.Pages.Add(MyPage)

'Create a TextArea
Dim area As TextArea = New TextArea("Hello TTC Testing", 100, 100, 100, 100)

'Create a open type font collection.
Dim collection As OpenTypeFontCollection = New OpenTypeFontCollection("Path of .ttc file")

'Assign opentype font to label from Collection using the Index
area.Font = collection.GetFont(3)

' Add a label to the page
MyPage.Elements.Add(area)

' Save the PDF document
MyDocument.Draw("C:\MyDocument.pdf")

End Sub
End Module
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.Text;
using ceTe.DynamicPDF.PageElements;
class Example
{
static void CreatePDF(string outputPath, string fontCollectionPath)
{
// Create a PDF Document
Document document = new Document();

// Create a new Page
Page page = new Page();

// Add the page to the document
document.Pages.Add(page);

//Create a TextArea
TextArea area = new TextArea("Hello TTC Testing", 100, 100, 100, 100);

//Create a open type font collection.
OpenTypeFontCollection collection = new OpenTypeFontCollection(fontCollectionPath);

//Assign opentype font to label from Collection using the Index
area.Font = collection.GetFont(3);

// Add label to the page
page.Elements.Add(area);

// Save the PDF document
document.Draw(outputPath);
}
}

GetFont(String)​

Gets the font from the Open type collection based on the font name.

public OpenTypeFont GetFont(string fontName)
Function GetFont(fontName As String) As OpenTypeFont

Parameters​

The name of the font in the collection to get.

Returns​

Opentype font based on the given font name.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Examples​

This example shows how to use the GetFont method using FontName.

Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
Imports ceTe.DynamicPDF.Text

Module MyModule

Sub CreatePDF()

' Create a PDF Document
Dim MyDocument As Document = New Document

' Create a Page and add it to the document
Dim MyPage As Page = New Page
MyDocument.Pages.Add(MyPage)

'Create a TextArea
Dim area As TextArea = New TextArea("Hello TTC Testing", 100, 100, 100, 100)

'Create a open type font collection.
Dim collection As OpenTypeFontCollection = New OpenTypeFontCollection("Path of .ttc file")

'Gets all font names present in the TTC
Dim fontNames() As String = collection.GetFontNames()

'Getting Font from collection using font name.
Dim font As OpenTypeFont = collection.GetFont(fontNames(3))

'Assign opentype font to label from Collection using the Index
area.Font = font

' Add a label to the page
MyPage.Elements.Add(area)

' Save the PDF document
MyDocument.Draw("C:\MyDocument.pdf")

End Sub
End Module
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.Text;
using ceTe.DynamicPDF.PageElements;
class Example
{
static void CreatePDF(string outputPath, string fontCollectionPath)
{
// Create a PDF Document
Document document = new Document();

// Create a new Page
Page page = new Page();

// Add the page to the document
document.Pages.Add(page);

//Create a TextArea
TextArea area = new TextArea("Hello TTC Testing", 100, 100, 100, 100);

//Create a open type font collection.
OpenTypeFontCollection collection = new OpenTypeFontCollection(fontCollectionPath);

//Gets all font names present in the TTC
string[] fontNames = collection.GetFontNames();

//Getting Font from collection using font name.
OpenTypeFont font = collection.GetFont(fontNames[3]);

//Assign opentype font to label
area.Font = font;

// Add label to the page
page.Elements.Add(area);

// Save the PDF document
document.Draw(outputPath);
}
}

GetFontNames()​

Gets the names of the fonts present in the open type collection.

public String[] GetFontNames()
Function GetFontNames() As String[]

Returns​

The font names array.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

GetHashCode()​

Serves as a hash function for a particular type. (Inherited from Object)

public int GetHashCode()
Function GetHashCode() As Integer

Returns​

A hash code for the current Object .

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

GetType()​

Gets the Type of the current instance. (Inherited from Object)

public Type GetType()
Function GetType() As Type

Returns​

The Type instance that represents the exact runtime type of the current instance.

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

ToString()​

Returns a String that represents the current Object . (Inherited from Object)

public string ToString()
Function ToString() As String

Returns​

A String that represents the current Object .

Licensing Info​

This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

See Also​

ceTe.DynamicPDF.Text