FontRepositoryOpenFont Method (String)
Opens font with specified font file path.

Namespace: Aspose.Pdf.Text
Assembly: Aspose.PDF (in Aspose.PDF.dll) Version: 20.1
Syntax
public static Font OpenFont(
	string fontFilePath
)

Parameters

fontFilePath
Type: SystemString
Font file path.

Return Value

Type: Font
Font object.
Examples
The example demonstrates how to open font and replace the font of text of first page.
C#
// Open font
Font font = FontRepository.OpenFont(@"C:\WINDOWS\Fonts\arial.ttf");

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");

// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");

// Accept the absorber for first page
doc.Pages[1].Accept(absorber);

// Change font of the first text occurrence
absorber.TextFragments[1].TextState.Font = font;

// Save document
doc.Save(@"D:\Tests\output.pdf");
See Also