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("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.getPages().get_Item(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.getTextFragments().get_Item(1).getTextState().setFont( font); // Save document doc.save("output.pdf");
TextFragmentAbsorber
,
FontRepository
,
IDocument
Modifier and Type | Method and Description |
---|---|
boolean |
doesFontContainAllCharacters(String value)
Determines if the font contains specified chars
|
String |
getFontName()
Gets font name of the
Font object. |
com.aspose.fonts.IFont |
getIFont()
System font object.
|
com.aspose.pdf.engine.commondata.text.fonts.IPdfFont |
getIPdfFont()
Pdf font object.
|
boolean |
isAccessible()
Gets indicating whether the font is present (installed) in the system.
|
boolean |
isEmbedded()
Gets a value that indicates whether the font is embedded.
|
boolean |
isSubset()
Gets a value that indicates whether the font is a subset.
|
void |
save(OutputStream stream)
Saves the font into the stream.
|
void |
setEmbedded(boolean value)
Sets a value that indicates whether the font is embedded.
|
void |
setSubset(boolean value)
Sets a value that indicates whether the font is a subset.
|
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.getPages().get_Item(1).accept(absorber); // View font name of first text occurrence System.out.println(absorber.getTextFragments().get_Item(1).getTextState().getFont().getFontName());
TextFragmentAbsorber
,
IDocument
public boolean isEmbedded()
Gets 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 com.aspose.pdf.Font font = com.aspose.pdf.FontRepository.findFont("Arial"); font.isEmbedded ( true); // open document com.aspose.pdf.Document doc = new com.aspose.pdf.Document("D:\\Tests\\input.pdf"); // create TextFragmentAbsorber object to find all "hello world" text occurrences com.aspose.pdf.TextFragmentAbsorber absorber = new com.aspose.pdf.TextFragmentAbsorber("hello world"); // accept the absorber for first page doc.getPages().get_Item(1).accept(absorber); // change font for the first text occurrence absorber.getTextFragments().get_Item(1).getTextState().setFont(font); // save document doc.save("D:\\Tests\\output.pdf");
TextFragmentAbsorber
,
FontRepository
,
IDocument
public void setEmbedded(boolean value)
Sets a value that indicates whether the font is embedded.
value
- boolean valuepublic boolean isSubset()
Gets 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.getPages().get_Item(1).accept(absorber); // View font's IsSubset value of first text occurrence if(absorber.TextFragments[1].TextState.Font.IsSubset) System.out.println("the font is a subset");
TextFragmentAbsorber
,
IDocument
public void setSubset(boolean value)
Sets a value that indicates whether the font is a subset.
value
- boolean valuepublic 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.getPages().get_Item(1).accept(absorber); // View font's IsSubset value of first text occurrence if (absorber.getTextFragments().get_Item(1).getTextState().getFont() .isAccessible()) System.out.println("the font is installed in the system");
public com.aspose.pdf.engine.commondata.text.fonts.IPdfFont getIPdfFont()
Pdf font object.
public com.aspose.fonts.IFont getIFont()
System font object.
public void save(OutputStream stream)
Saves the font into the stream. Note that the font is saved to intermediate TTF format intended to be used in a converted copy of the original document only. The font file is not intended to be used outside the original document context.
stream
- OutputStream to save the font.public boolean doesFontContainAllCharacters(String value)
Determines if the font contains specified chars
Copyright © 2016 Aspose. All Rights Reserved.