FontRepository.FindFont

FindFont(string)

Searches and returns font with specified font name.

public static Font FindFont(string fontName)
ParameterTypeDescription
fontNameStringFont name.

Return Value

Font object.

Examples

The example demonstrates how to find font and replace the font of text of first page.

// Find font
Font font = FontRepository.FindFont("Arial");

// 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


FindFont(string, bool)

Searches and returns font with specified font name ignoring or honoring case sensitivity.

public static Font FindFont(string fontName, bool ignoreCase)
ParameterTypeDescription
fontNameStringFont name.
ignoreCaseBooleancase sensitivity

Return Value

Font object.

Examples

The example demonstrates how to find font and replace the font of text of first page.

// Find font
Font font = FontRepository.FindFont("Arial");

// 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


FindFont(string, FontStyles)

Searches and returns font with specified font name and font style.

public static Font FindFont(string fontFamilyName, FontStyles stl)
ParameterTypeDescription
fontFamilyNameStringFont family name.
stlFontStylesFont style value.

Return Value

Font object corresponding to search request parameters.

Examples

The example demonstrates how to find font and replace the font of text of first page.

// Find font
Font font = FontRepository.FindFont("Arial", FontStyle.Italic);

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

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

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

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

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

See Also


FindFont(string, FontStyles, bool)

Searches and returns font with specified font name and font style ignoring or honoring case sensitivity.

public static Font FindFont(string fontFamilyName, FontStyles stl, bool ignoreCase)
ParameterTypeDescription
fontFamilyNameStringFont family name.
stlFontStylesFont style value.
ignoreCaseBooleancase sensitivity

Return Value

Font object corresponding to search request parameters.

Examples

The example demonstrates how to find font and replace the font of text of first page.

// Find font
Font font = FontRepository.FindFont("Arial", FontStyle.Italic);

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

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

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

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

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

See Also