com.aspose.pdf

Interfaces

Classes

Enums

Exceptions

com.aspose.pdf

Class FontCollection

  • All Implemented Interfaces:
    Iterable<Font>


    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.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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.
    • Method Detail

      • size

        public int size()

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

        Returns:
        int value
      • getSyncRoot

        public Object getSyncRoot()

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

        Returns:
        Object for synchronization
      • isSynchronized

        public boolean isSynchronized()

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

        Returns:
        boolean value
      • isReadOnly

        public boolean isReadOnly()

        Gets a value indicating whether collection is read-only

        Returns:
        boolean value
      • iterator_Rename_Namesake

        public com.aspose.ms.System.Collections.IEnumerator iterator_Rename_Namesake()

        Returns an enumerator for the entire collection.

        Returns:
        Enumerator object.
      • iterator

        public Iterator<Font> iterator()

        Returns an enumerator for the entire collection.

        Specified by:
        iterator in interface Iterable<Font>
        Returns:
        Enumerator object.
      • copyTo

        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:
        array - Array of objects which will be copied.
        index - Starting index from which copying will be started.
      • add

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

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

        Parameters:
        newFont - Font object.
        resName - The automatically assigned resource item name.
      • add

        public void add(Font fragment)

        Adds Font into collection.

        Parameters:
        fragment - Font object
      • get_Item

        public Font get_Item(int index)

        Gets the font element at the specified index.

        Parameters:
        index - Index within the collection.
        Returns:
        Font object.
      • get_Item

        public Font get_Item(String name)

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

        Parameters:
        name - Name of the font.
        Returns:
        Found font.
      • contains

        public boolean contains(String name)

        Checks if font exists in font collection.

        Parameters:
        name - Font name.
        Returns:
        True in case collection contains the font with specified name.
      • getHash

        public com.aspose.pdf.engine.collections.HashDictionary<String,Font> getHash()
      • add

        public void add(String resName,
                        com.aspose.pdf.engine.data.IPdfObject newFont)

        Add new font to font collection.

        Parameters:
        resName - String object
        newFont - IPdfObject object
      • add

        public void add(String resName,
                        String baseFontName)

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

        Parameters:
        resName - String object
        baseFontName - String object
      • clear_Rename_Namesake

        public void clear_Rename_Namesake()

        Clears all items from the collection.

      • contains

        public boolean contains(Font item)

        Determines whether the collection contains a specific value.

        Parameters:
        item - The object to locate in the collection
        Returns:
        true if item is found in the collection; otherwise, false.
      • remove

        public boolean remove(Font item)

        Deletes specified item from collection.

        Parameters:
        item - The object to delete
        Returns:
        true if item was deleted from collection; otherwise, false.