FontCollection

Inheritance: java.lang.Object

All Implemented Interfaces: java.lang.Iterable

public final class FontCollection 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.

Methods

MethodDescription
size()Gets the number of Font object elements actually contained in the collection.
getSyncRoot()Gets an object that can be used to synchronize access to the collection.
isSynchronized()Gets a value indicating whether access to the collection is synchronized (thread safe).
isReadOnly()Gets a value indicating whether collection is read-only
iterator_Rename_Namesake()Returns an enumerator for the entire collection.
iterator()Returns an enumerator for the entire collection.
copyTo(Font[] array, int index)Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array
add(Font newFont, String[] resName)Adds new font to font resources and returns automatically assigned name of font resource.
add(Font fragment)Adds Font into collection.
get_Item(int index)Gets the font element at the specified index.
get_Item(String name)Gets font from the collection by font name.
contains(String name)Checks if font exists in font collection.
getHash()
add(String resName, IPdfObject newFont)Add new font to font collection.
add(String resName, String baseFontName)Adds to font resources new font entry with specified base font name.
clear_Rename_Namesake()Clears all items from the collection.
contains(Font item)Determines whether the collection contains a specific value.
remove(Font item)Deletes specified item from collection.

size()

public int size()

Gets the number of Font object elements actually contained in the collection.

Returns: int - int value

getSyncRoot()

public Object getSyncRoot()

Gets an object that can be used to synchronize access to the collection.

Returns: java.lang.Object - Object for synchronization

isSynchronized()

public boolean isSynchronized()

Gets a value indicating whether access to the collection is synchronized (thread safe).

Returns: boolean - boolean value

isReadOnly()

public boolean isReadOnly()

Gets a value indicating whether collection is read-only

Returns: boolean - boolean value

iterator_Rename_Namesake()

public System.Collections.IEnumerator iterator_Rename_Namesake()

Returns an enumerator for the entire collection.

Returns: com.aspose.ms.System.Collections.IEnumerator - Enumerator object.

iterator()

public Iterator<Font> iterator()

Returns an enumerator for the entire collection.

Returns: java.util.Iterator<com.aspose.pdf.Font> - Enumerator object.

copyTo(Font[] array, int index)

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

Parameters:

ParameterTypeDescription
arrayFont[]Array of objects which will be copied.
indexintStarting index from which copying will be started.

add(Font newFont, String[] resName)

public void add(Font newFont, String[] resName)

Adds new font to font resources and returns automatically assigned name of font resource.

Parameters:

ParameterTypeDescription
newFontFontFont object.
resNamejava.lang.String[]The automatically assigned resource item name.

add(Font fragment)

public void add(Font fragment)

Adds Font into collection.

Parameters:

ParameterTypeDescription
fragmentFontFont object

get_Item(int index)

public Font get_Item(int index)

Gets the font element at the specified index.

Parameters:

ParameterTypeDescription
indexintIndex within the collection.

Returns: Font - Font object.

get_Item(String name)

public Font get_Item(String name)

Gets font from the collection by font name. Exception is thrown if font was not found.

Parameters:

ParameterTypeDescription
namejava.lang.StringName of the font.

Returns: Font - Found font.

contains(String name)

public boolean contains(String name)

Checks if font exists in font collection.

Parameters:

ParameterTypeDescription
namejava.lang.StringFont name.

Returns: boolean - True in case collection contains the font with specified name.

getHash()

public HashDictionary<String,Font> getHash()

Returns: HashDictionary

add(String resName, IPdfObject newFont)

public void add(String resName, IPdfObject newFont)

Add new font to font collection.

Parameters:

ParameterTypeDescription
resNamejava.lang.StringString object
newFontIPdfObjectIPdfObject object

add(String resName, String baseFontName)

public void add(String resName, String baseFontName)

Adds to font resources new font entry with specified base font name.

Parameters:

ParameterTypeDescription
resNamejava.lang.StringString object
baseFontNamejava.lang.StringString object

clear_Rename_Namesake()

public void clear_Rename_Namesake()

Clears all items from the collection.

contains(Font item)

public boolean contains(Font item)

Determines whether the collection contains a specific value.

Parameters:

ParameterTypeDescription
itemFontThe object to locate in the collection

Returns: boolean - true if item is found in the collection; otherwise, false.

remove(Font item)

public boolean remove(Font item)

Deletes specified item from collection.

Parameters:

ParameterTypeDescription
itemFontThe object to delete

Returns: boolean - true if item was deleted from collection; otherwise, false.