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 the font element at the specified index.
      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.
      boolean contains(String name)
      Checks if font exists in font collection.
      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.
      Object getSyncRoot()
      Gets an object that can be used to synchronize access to the collection.
      boolean isSynchronized()
      Gets a value indicating whether access to the collection is synchronized (thread safe).
      com.aspose.ms.System.Collections.IEnumerator iterator()
      Returns an enumerator for the entire 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
      • iterator

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

        Returns an enumerator for the entire collection.

        Specified by:
        iterator in interface Iterable<Font>
        Returns:
        Enumerator object.
      • 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 the font element at the specified index.

        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.
      • 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