public final class Font extends Object implements Cloneable
Represents font object.
The example demonstrates how to search text on first page and change font of a first search occurrence.// 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); // Create font and mark it to be embedded Font font = FontRepository.FindFont("Arial"); font.IsEmbedded = true; // Change font of the first text occurrence absorber.TextFragments[1].TextState.Font = font; // Save document doc.Save(@"D:\Tests\output.pdf");
TextFragmentAbsorber
,
FontRepository
,
Document
Modifier and Type | Method and Description |
---|---|
String |
getFontName()
Gets font name of the
Font object. |
com.aspose.fonts.IFont |
getIFont()
System font object.
|
boolean |
isAccessible()
Gets indicating whether the font is present (installed) in the system.
|
boolean |
isEmbedded()
Gets or sets a value that indicates whether the font is embedded.
|
void |
isEmbedded(boolean value) |
boolean |
isSubset()
Gets or sets a value that indicates whether the font is a subset.
|
void |
isSubset(boolean value) |
public String getFontName()
Gets font name of the Font
object.
The example demonstrates how to search text on first page and view font name of a first text occurrence.// 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); // View font name of first text occurrence Console.Out.WriteLine(absorber.TextFragments[1].TextState.Font.FontName);
TextFragmentAbsorber
,
Document
public boolean isEmbedded()
Gets or sets a value that indicates whether the font is embedded.
The following example demonstrates how to find a font, mark it as embedded, search text on the document's page and replace the text font.// Create font and mark it to be embedded Font font = FontRepository.FindFont("Arial"); font.IsEmbedded = true; // 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 for the first text occurrence absorber.TextFragments[1].TextState.Font = font; // save document doc.Save(@"D:\Tests\output.pdf");
TextFragmentAbsorber
,
FontRepository
,
Document
public void isEmbedded(boolean value)
public boolean isSubset()
Gets or sets a value that indicates whether the font is a subset.
The example demonstrates how to search text on first page and get the value that indicates whether the font is a subset.// 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); // View font's IsSubset value of first text occurrence if(absorber.TextFragments[1].TextState.Font.IsSubset) Console.Out.WriteLine("the font is a subset");
TextFragmentAbsorber
,
Document
public void isSubset(boolean value)
public boolean isAccessible()
Gets indicating whether the font is present (installed) in the system.
The example demonstrates how to search text on first page and get the value that indicates whether the font is installed in the system.// 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); // View font's IsSubset value of first text occurrence if(absorber.TextFragments[1].TextState.Font.IsAccessible) Console.Out.WriteLine("the font is installed in the system");
TextFragmentAbsorber
,
Document
public com.aspose.fonts.IFont getIFont()
System font object.
Copyright © 2019 Aspose. All Rights Reserved.