com.aspose.pdf.facades

Class PdfXmpMetadata

  • All Implemented Interfaces:
    com.aspose.ms.System.Collections.ICollection, com.aspose.ms.System.Collections.IDictionary, com.aspose.ms.System.Collections.IEnumerable, com.aspose.ms.System.IDisposable, IFacade, ISaveableFacade, Iterable


    public final class PdfXmpMetadata
    extends SaveableFacade
    implements com.aspose.ms.System.Collections.IDictionary

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

        public void add(int key,
                        Object 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.IDictionary
      • remove

        public void remove(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
      • remove

        public void remove(XmpPdfAExtensionObject key)

        Removes pdf extension field.

        Parameters:
        key - The key of value to remove.
      • addItem

        public void addItem(Object key,
                            Object 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.IDictionary
        Parameters:
        key - Key of new element.
        value - Value of the element.
      • contains

        public boolean contains(Object 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");
         
        Specified by:
        contains in interface com.aspose.ms.System.Collections.IDictionary
        Parameters:
        key - Key which will be checked.
        Returns:
        True - if the dictionary contains the specified key; otherwise, false.
      • iterator

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

        Gets enumerator object of the dictionary.

        Specified by:
        iterator in interface com.aspose.ms.System.Collections.IDictionary
        Specified by:
        iterator in interface com.aspose.ms.System.Collections.IEnumerable
        Specified by:
        iterator in interface Iterable
        Returns:
        The enumerator object.
      • getKeys

        public com.aspose.ms.System.Collections.ICollection getKeys()

        Gets keys from the dictionary.

        Specified by:
        getKeys in interface com.aspose.ms.System.Collections.IDictionary
        Returns:
        ICollection element
      • removeItem

        public void removeItem(Object key)

        Removes key from the dictionary.


         
         
         PdfXmpMetadata xmp = new PdfXmpMetadata();
         xmp.bindPdf("input.pdf");
         xmp.remove("xmp:Nickname");
         
        Specified by:
        removeItem in interface com.aspose.ms.System.Collections.IDictionary
        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.ICollection getValues()

        Gets the collection of values in dictionary.

        Specified by:
        getValues in interface com.aspose.ms.System.Collections.IDictionary
        Returns:
        ICollection object
      • get_Item

        public Object get_Item(Object 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.IDictionary
        Parameters:
        key - The key name to get.
        Returns:
        Object by key
      • set_Item

        public void set_Item(Object key,
                             Object 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.IDictionary
        Parameters:
        key - The key name to set.
        value - The value to set.
      • isFixedSize

        public boolean isFixedSize()

        Returns true is collection has fixed size.

        Specified by:
        isFixedSize in interface com.aspose.ms.System.Collections.IDictionary
        Returns:
        boolean value
      • isReadOnly

        public boolean isReadOnly()

        Returns true if collection is read-only.

        Specified by:
        isReadOnly in interface com.aspose.ms.System.Collections.IDictionary
        Returns:
        boolean value
      • copyTo

        public void copyTo(com.aspose.ms.System.Array array,
                           int index)

        Copy metadata into array.

        Specified by:
        copyTo in interface com.aspose.ms.System.Collections.ICollection
        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.ICollection
        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.

        Specified by:
        isSynchronized in interface com.aspose.ms.System.Collections.ICollection
        Returns:
        boolean value
      • getSyncRoot

        public Object getSyncRoot()

        Gets synchroniztion object of the collection.

        Specified by:
        getSyncRoot in interface com.aspose.ms.System.Collections.ICollection
        Returns:
        Object element
      • iteratorIt

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

        Gets enumerator object of the collection.

        Returns:
        IEnumerator object
      • getByDefaultMetadataProperties

        public Object 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,
                                                   Object 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.