OpenTypeFontCollection.GetFont
Overloads
GetFont(Int32) | Gets the font from the Open type collection based on the index. |
GetFont(String) | Gets the font from the Open type collection based on the font name. |
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
- Int32
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:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
Examples
This example shows how to use the GetFont method using IndexImports 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
- fontName
- String
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:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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);
}
}