com.aspose.pdf.facades

Class PdfXmpMetadata

  • All Implemented Interfaces:
    com.aspose.ms.System.Collections.Generic.IGenericCollection<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>, com.aspose.ms.System.Collections.Generic.IGenericDictionary<String,com.aspose.pdf.engine.data.xmp.XmpValue>, com.aspose.ms.System.Collections.Generic.IGenericEnumerable<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>, com.aspose.ms.System.Collections.IEnumerable<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>, com.aspose.ms.System.IDisposable, IFacade, ISaveableFacade, Iterable<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>


    public final class PdfXmpMetadata
    extends SaveableFacade
    implements com.aspose.ms.System.Collections.Generic.IGenericDictionary<String,com.aspose.pdf.engine.data.xmp.XmpValue>

    Class for manipulation with XMP metadata.

    • Constructor Detail

      • PdfXmpMetadata

        public PdfXmpMetadata()

        Constructor for PdfXmpMetadata.


        
        
         PdfXmlMetadata xmp = new PdfXmpMetadata();
         xmp.bindPdf("input.pdf");
         
      • PdfXmpMetadata

        public PdfXmpMetadata(IDocument document)

        Initializes new PdfXmpMetadata object on base of the document.

        Parameters:
        document - Pdf document.
    • Method Detail

      • registerNamespaceURI

        public void registerNamespaceURI(String prefix,
                                         String namespaceURI)

        Registers the namespace URI.


        
        
         PdfXmpMetadata xmp = new PdfXmpMetadata("input.pdf");
         xmp.registerNamespaceURI("xmp", "http://ns.adobe.com/xap/1.0/");
         
        Parameters:
        prefix - The prefix.
        namespaceURI - The namespace URI.
      • getNamespaceURIByPrefix

        public String getNamespaceURIByPrefix(String prefix)

        Gets namespace URI by prefix.


        
        
         PdfXmpMetadata xmp = new PdfXmpMetadata("input.pdf");
         System.out.println(xmp.getNamespaceURIByPrefix("xmp"));
         
        Parameters:
        prefix - The prefix.
        Returns:
        Namespace URI.
      • getPrefixByNamespaceURI

        public String getPrefixByNamespaceURI(String namespaceURI)

        Gets the prefix by namespace URI.


        
        
         PdfXmpMetadata xmp = new PdfXmpMetadata("input.pdf");
         System.out.println(xmp.getPrefixByNamespaceURI("http://ns.adobe.com/xap/1.0/"));
         
        Parameters:
        namespaceURI - Namespace URI.
        Returns:
        The prefix value.
      • addItem

        public void addItem(int key,
                            com.aspose.pdf.engine.data.xmp.XmpValue value)

        Adds value to XMP metadata.


        
        
         PdfXmpMetadata xmp = new PdfXmpMetadata();
         xmp.bindPdf("input.pdf");
         xmp.add(DefaultMetadataProperties.Nickname, "name1");
         xmp.save(TestSettings.getOutputFile("XMP_AddedValue.pdf"));
         
        Parameters:
        key - The key name.
        value - Value which will be added.
      • add

        public void add(XmpPdfAExtensionObject xmpPdfAExtensionObject,
                        String namespacePrefix,
                        String namespaceUri,
                        String schemaDescription)

        Adds extension field into metadata.

        Parameters:
        xmpPdfAExtensionObject - The pdf extension object to add.
        namespacePrefix - The prefix of schema.
        namespaceUri - The namespace uri of schema.
        schemaDescription - The optional description of schema.
      • clear

        public void clear()

        Removes all elements from the object.


        
        
         PdfXmpMetadata xmp = new PdfXmpMetadata();
         xmp.bindPdf("input.pdf");
         xmp.clear();
         
        Specified by:
        clear in interface com.aspose.ms.System.Collections.Generic.IGenericCollection<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>
      • removeItemByKey

        public void removeItemByKey(int key)

        Removes element with specified key.


        
        
         PdfXmpMetadata xmp = new PdfXmpMetadata();
         xmp.bindPdf("input.pdf");
         xmp.remove(DefaultMetadataProperties.Nickname);
         
        Parameters:
        key - Key of the element which will be deleted.
        See Also:
        DefaultMetadataProperties
      • addItem

        public void addItem(String key,
                            com.aspose.pdf.engine.data.xmp.XmpValue value)

        Adds new element to the dictionary object.


        
        
         PdfXmpMetadata xmp = new PdfXmpMetadata();
         xmp.bindPdf("input.pdf");
         xmp.add("xmp:Nickname", "Nickname1");
         
        Specified by:
        addItem in interface com.aspose.ms.System.Collections.Generic.IGenericDictionary<String,com.aspose.pdf.engine.data.xmp.XmpValue>
        Parameters:
        key - Key of new element.
        value - Value of the element.
      • addItem

        public void addItem(String key,
                            Object value)

        Adds new element to the dictionary object.

        Parameters:
        key - Key of new element.
        value - Value of the element.
      • contains

        public boolean contains(String key)

        Checks if dictionary contains the specified key.


        
        
         PdfXmpMetadata xmp = new PdfXmpMetadata();
         xmp.bindPdf("input.pdf");
         xmp.add("xmp:Nickname", "Nickname1");
         if (!xmp.contains("xmp:Nickname"))
           System.out.println("Key does not exists");
         
        Parameters:
        key - Key which will be checked.
        Returns:
        True - if the dictionary contains the specified key; otherwise, false.
      • contains

        public boolean contains(int property)

        Checks if dictionary contains the specified property.

        Parameters:
        property - Property which will be checked.
        Returns:
        True - if the dictionary contains the specified property; otherwise, false.
      • iterator

        public com.aspose.ms.System.Collections.Generic.IGenericEnumerator<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>> iterator()

        Gets enumerator object of the dictionary.

        Specified by:
        iterator in interface com.aspose.ms.System.Collections.Generic.IGenericEnumerable<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>
        Specified by:
        iterator in interface com.aspose.ms.System.Collections.IEnumerable<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>
        Specified by:
        iterator in interface Iterable<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>
        Returns:
        The enumerator object.
      • getKeys

        public com.aspose.ms.System.Collections.Generic.IGenericCollection<String> getKeys()

        Gets keys from the dictionary.

        Specified by:
        getKeys in interface com.aspose.ms.System.Collections.Generic.IGenericDictionary<String,com.aspose.pdf.engine.data.xmp.XmpValue>
        Returns:
        ICollection element
      • removeItemByKey

        public boolean removeItemByKey(String key)

        Removes key from the dictionary.


        
        
         PdfXmpMetadata xmp = new PdfXmpMetadata();
         xmp.bindPdf("input.pdf");
         xmp.remove("xmp:Nickname");
         
        Specified by:
        removeItemByKey in interface com.aspose.ms.System.Collections.Generic.IGenericDictionary<String,com.aspose.pdf.engine.data.xmp.XmpValue>
        Parameters:
        key - Key which will be removed.
      • getExtensionFields

        public Hashtable<String,XmpPdfAExtensionSchema> getExtensionFields()

        Gets the dictionary of extension fields.

        Returns:
        Hashtable<String, XmpPdfAExtensionSchema> object
      • getValues

        public com.aspose.ms.System.Collections.Generic.IGenericCollection<com.aspose.pdf.engine.data.xmp.XmpValue> getValues()

        Gets the collection of values in dictionary.

        Specified by:
        getValues in interface com.aspose.ms.System.Collections.Generic.IGenericDictionary<String,com.aspose.pdf.engine.data.xmp.XmpValue>
        Returns:
        ICollection object
      • get_Item

        public com.aspose.pdf.engine.data.xmp.XmpValue get_Item(String key)

        Gets value by key.


        
        
         PdfXmpMetadata pxm = new PdfXmpMetadata();
         pxm.bindPdf("PdfFile.pdf");
         System.out.println(pxm.get_Item("xmp:Nickname"));
         
        Specified by:
        get_Item in interface com.aspose.ms.System.Collections.Generic.IGenericDictionary<String,com.aspose.pdf.engine.data.xmp.XmpValue>
        Parameters:
        key - The key name to get.
        Returns:
        Object by key
      • set_Item

        public void set_Item(String key,
                             com.aspose.pdf.engine.data.xmp.XmpValue value)

        Sets value by key.


        
        
         PdfXmpMetadata pxm = new PdfXmpMetadata();
         pxm.bindPdf("PdfFile.pdf");
         System.out.println(pxm.get_Item("xmp:Nickname"));
         
        Specified by:
        set_Item in interface com.aspose.ms.System.Collections.Generic.IGenericDictionary<String,com.aspose.pdf.engine.data.xmp.XmpValue>
        Parameters:
        key - The key name to set.
        value - The value to set.
      • isFixedSize

        public boolean isFixedSize()

        Returns true is collection has fixed size.

        Returns:
        boolean value
      • isReadOnly

        public boolean isReadOnly()

        Returns true if collection is read-only.

        Specified by:
        isReadOnly in interface com.aspose.ms.System.Collections.Generic.IGenericCollection<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>
        Returns:
        boolean value
      • copyToTArray

        public void copyToTArray(com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>[] array,
                                 int index)

        Copy metadata into array.

        Specified by:
        copyToTArray in interface com.aspose.ms.System.Collections.Generic.IGenericCollection<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>
        Parameters:
        array - The destination array.
        index - The starting index.
      • size

        public int size()

        Gets count if items in the collection.

        Specified by:
        size in interface com.aspose.ms.System.Collections.Generic.IGenericCollection<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>
        Returns:
        int value
        
        
         PdfXmpMetadata pxm = new PdfXmpMetadata();
         pxm.bindPdf("PdfFile.pdf");
         System.out.println("Count = " + pxm.size());
         
      • isSynchronized

        public boolean isSynchronized()

        Returns true if collection is synchronized.

        Returns:
        boolean value
      • getSyncRoot

        public Object getSyncRoot()

        Gets synchroniztion object of the collection.

        Returns:
        Object element
      • iteratorIt

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

        Gets enumerator object of the collection.

        Returns:
        IEnumerator object
      • iterator_Rename_Namesake

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

        public com.aspose.pdf.engine.data.xmp.XmpValue getByDefaultMetadataProperties(int key)

        Gets value of XMP metadata by key.


        
        
         PdfXmpMetadata pxm = new PdfXmpMetadata();
         pxm.bindPdf("PdfFile.pdf");
         System.out.println(pxm.get_Item(DefaultMetadataProperties.CreatorTool));
         
        Parameters:
        key - Key of the value.
        Returns:
        Value from XMP metadata.
        See Also:
        DefaultMetadataProperties
      • setByDefaultMetadataProperties

        public void setByDefaultMetadataProperties(int key,
                                                   com.aspose.pdf.engine.data.xmp.XmpValue value)

        Sets value of XMP metadata by key.


        
        
         PdfXmpMetadata pxm = new PdfXmpMetadata();
         pxm.bindPdf("PdfFile.pdf");
         System.out.println(pxm.get_Item(DefaultMetadataProperties.CreatorTool));
         
        Parameters:
        key - Key of the DefaultMetadataProperties value.
        value - Object.
        See Also:
        DefaultMetadataProperties
      • getXmpMetadata

        public byte[] getXmpMetadata()

        Get the XmpMetadata of the input pdf in a xml format.


        
        
         PdfXmpMetadata pxm = new PdfXmpMetadata();
         pxm.bindPdf("PdfFile.pdf");
         byte[] data = pxm.getXmpMetadata();
         
        Returns:
        The bytes of the XmpMetadata.
      • getXmpMetadata

        public byte[] getXmpMetadata(String name)

        Get a part of the XmpMetadata of the input pdf according to a meta name.


        
        
         PdfXmpMetadata pxm = new PdfXmpMetadata();
         pxm.bindPdf("PdfFile.pdf");
         byte[] data = pxm.getXmpMetadata("dc:creator");
         
        Parameters:
        name - Metadata name.
        Returns:
        Bytes of metadata.
      • containsKey

        public boolean containsKey(String key)

        Determines does this dictionary contasins specified key.

        Specified by:
        containsKey in interface com.aspose.ms.System.Collections.Generic.IGenericDictionary<String,com.aspose.pdf.engine.data.xmp.XmpValue>
        Parameters:
        key - Key to search in the dictionary.
        Returns:
        true if key is found.
      • tryGetValue

        public boolean tryGetValue(String key,
                                   Object[] value)

        Tries to find key in the dictionary and retreives value if found.

        Specified by:
        tryGetValue in interface com.aspose.ms.System.Collections.Generic.IGenericDictionary<String,com.aspose.pdf.engine.data.xmp.XmpValue>
        Parameters:
        key - Key to search in the dictionary.
        value - Retreived value.
        Returns:
        true if key was found.
      • addItem

        public void addItem(com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue> item)

        Adds pair with key and value into the dictionary.

        Specified by:
        addItem in interface com.aspose.ms.System.Collections.Generic.IGenericCollection<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>
        Parameters:
        item - Item to be added.
      • containsItem

        public boolean containsItem(com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue> item)

        Checks does specified key-value pair is contained in the dictionary.

        Specified by:
        containsItem in interface com.aspose.ms.System.Collections.Generic.IGenericCollection<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>
        Parameters:
        item - Key-value pair.
        Returns:
        true if this pauir was found.
      • removeItem

        public boolean removeItem(com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue> item)

        Removes key/value pair from the colleciton.

        Specified by:
        removeItem in interface com.aspose.ms.System.Collections.Generic.IGenericCollection<com.aspose.ms.System.Collections.Generic.KeyValuePair<String,com.aspose.pdf.engine.data.xmp.XmpValue>>
        Parameters:
        item - Key/value pair to be removed.
        Returns:
        true if pair was found and removed.