Class FontCollection

FontCollection class

Represents font collection.

public sealed class FontCollection : ICollection<Font>


Count { get; }Gets the number of Font object elements actually contained in the collection.
IsReadOnly { get; }Gets a value indicating whether collection is read-only
IsSynchronized { get; }Gets a value indicating whether access to the collection is synchronized (thread safe).
Item { get; }Gets the font element at the specified index. (2 indexers)
SyncRoot { get; }Gets an object that can be used to synchronize access to the collection.


Add(Font, out string)Adds new font to font resources and returns automatically assigned name of font resource.
Contains(Font)Determines whether the collection contains a specific value.
Contains(string)Checks if font exists in font collection.
CopyTo(Font[], int)Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array
GetEnumerator()Returns an enumerator for the entire collection.
Remove(Font)Deletes specified item from collection.


Font collections represented by FontCollection class are used in several scenarios. For example, in resources with Fonts property.


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
foreach(Aspose.Pdf.Txt.Font font in doc.Pages[1].Resources.Fonts)
        font.IsEmbedded = true;


See Also