public final class FontCollection extends Object implements Iterable<Font>
Represents font collection.
The example demonstrates how to make all font declared on page as embedded. // Open document Document doc = new Document("D:\\Tests\\input.pdf"); // ensure all fonts declared on page resources are embedded // note that if fonts are declared on form resources they are not accessible from page resources for(com.aspsoe.pdf.Font font : doc.getPages().get_Item(1).getResources().getFonts()) { if(!font.isEmbedded()) font.isEmbedded(true); } doc.save("D:\\Tests\\input.pdf");
Font collections represented by FontCollection
class are used in several scenarios. For
example, in resources with Resources.Fonts
property.
Modifier and Type | Method and Description |
---|---|
void |
add(Font fragment)
Adds Font into collection.
|
void |
add(Font newFont,
String[] resName)
Adds new font to font resources and returns automatically assigned name of font resource.
|
void |
add(String resName,
com.aspose.pdf.engine.data.IPdfObject newFont)
Add new font to font collection.
|
void |
add(String resName,
String baseFontName)
Adds to font resources new font entry with specified base font name.
|
void |
clear_Rename_Namesake()
Clears all items from the collection.
|
boolean |
contains(Font item)
Determines whether the collection contains a specific value.
|
boolean |
contains(String name)
Checks if font exists in font collection.
|
void |
copyTo(Font[] array,
int index)
Copies the entire collection to a compatible one-dimensional Array, starting at the specified
index of the target array
|
Font |
get_Item(int index)
Gets the font element at the specified index.
|
Font |
get_Item(String name)
Gets font from the collection by font name.
|
com.aspose.pdf.engine.collections.HashDictionary<String,Font> |
getHash() |
Object |
getSyncRoot()
Gets an object that can be used to synchronize access to the collection.
|
boolean |
isReadOnly()
Gets a value indicating whether collection is read-only
|
boolean |
isSynchronized()
Gets a value indicating whether access to the collection is synchronized (thread safe).
|
com.aspose.ms.System.Collections.IEnumerator |
iterator_Rename_Namesake()
Returns an enumerator for the entire collection.
|
Iterator<Font> |
iterator()
Returns an enumerator for the entire collection.
|
boolean |
remove(Font item)
Deletes specified item from collection.
|
int |
size()
Gets the number of
Font object elements actually contained in the collection. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public int size()
Gets the number of Font
object elements actually contained in the collection.
public Object getSyncRoot()
Gets an object that can be used to synchronize access to the collection.
public boolean isSynchronized()
Gets a value indicating whether access to the collection is synchronized (thread safe).
public boolean isReadOnly()
Gets a value indicating whether collection is read-only
public com.aspose.ms.System.Collections.IEnumerator iterator_Rename_Namesake()
Returns an enumerator for the entire collection.
public void copyTo(Font[] array, int index)
Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array
array
- Array of objects which will be copied.index
- Starting index from which copying will be started.public void add(Font newFont, String[] resName)
Adds new font to font resources and returns automatically assigned name of font resource.
newFont
- Font object.resName
- The automatically assigned resource item name.public void add(Font fragment)
Adds Font into collection.
fragment
- Font objectpublic Font get_Item(int index)
Gets the font element at the specified index.
index
- Index within the collection.public Font get_Item(String name)
Gets font from the collection by font name. Exception is thrown if font was not found.
name
- Name of the font.public boolean contains(String name)
Checks if font exists in font collection.
name
- Font name.public void add(String resName, com.aspose.pdf.engine.data.IPdfObject newFont)
Add new font to font collection.
resName
- String objectnewFont
- IPdfObject objectpublic void add(String resName, String baseFontName)
Adds to font resources new font entry with specified base font name.
resName
- String objectbaseFontName
- String objectpublic void clear_Rename_Namesake()
Clears all items from the collection.
public boolean contains(Font item)
Determines whether the collection contains a specific value.
item
- The object to locate in the collectionpublic boolean remove(Font item)
Deletes specified item from collection.
item
- The object to delete