PdfXmpMetadata

Inheritance: java.lang.Object, com.aspose.pdf.facades.IVentureLicenseTarget, com.aspose.pdf.facades.Facade, com.aspose.pdf.facades.SaveableFacade

All Implemented Interfaces: com.aspose.ms.System.Collections.Generic.IGenericDictionary

public final class PdfXmpMetadata extends SaveableFacade implements System.Collections.Generic.IGenericDictionary<String,XmpValue>

Class for manipulation with XMP metadata.

Constructors

ConstructorDescription
PdfXmpMetadata()Constructor for PdfXmpMetadata.
PdfXmpMetadata(IDocument document)Initializes new PdfXmpMetadata object on base of the document .

Methods

MethodDescription
registerNamespaceURI(String prefix, String namespaceURI)Registers the namespace URI.
getNamespaceURIByPrefix(String prefix)Gets namespace URI by prefix.
getPrefixByNamespaceURI(String namespaceURI)Gets the prefix by namespace URI.
addItem(int key, XmpValue value)Adds value to XMP metadata.
add(XmpPdfAExtensionObject xmpPdfAExtensionObject, String namespacePrefix, String namespaceUri, String schemaDescription)Adds extension field into metadata.
clear()Removes all elements from the object.
removeItemByKey(int key)Removes element with specified key.
addItem(String key, XmpValue value)Adds new element to the dictionary object.
addItem(String key, Object value)Adds new element to the dictionary object.
contains(String key)Checks if dictionary contains the specified key.
contains(int property)Checks if dictionary contains the specified property.
iterator()Gets enumerator object of the dictionary.
getKeys()Gets keys from the dictionary.
removeItemByKey(String key)Removes key from the dictionary.
getExtensionFields()Gets the dictionary of extension fields.
getValues()Gets the collection of values in dictionary.
get_Item(String key)Gets value by key.
set_Item(String key, XmpValue value)Sets value by key.
isFixedSize()Returns true is collection has fixed size.
isReadOnly()Returns true if collection is read-only.
copyToTArray(System.Collections.Generic.KeyValuePair<String,XmpValue>[] array, int index)Copy metadata into array.
size()Gets count if items in the collection.
isSynchronized()Returns true if collection is synchronized.
getSyncRoot()Gets synchroniztion object of the collection.
iteratorIt()Gets enumerator object of the collection.
iterator_Rename_Namesake()
getByDefaultMetadataProperties(int key)Gets value of XMP metadata by key.
setByDefaultMetadataProperties(int key, XmpValue value)Sets value of XMP metadata by key.
getXmpMetadata()Get the XmpMetadata of the input pdf in a xml format.
getXmpMetadata(String name)Get a part of the XmpMetadata of the input pdf according to a meta name.
containsKey(String key)Determines does this dictionary contasins specified key.
tryGetValue(String key, Object[] value)Tries to find key in the dictionary and retreives value if found.
addItem(System.Collections.Generic.KeyValuePair<String,XmpValue> item)Adds pair with key and value into the dictionary.
containsItem(System.Collections.Generic.KeyValuePair<String,XmpValue> item)Checks does specified key-value pair is contained in the dictionary.
removeItem(System.Collections.Generic.KeyValuePair<String,XmpValue> item)Removes key/value pair from the collection.

PdfXmpMetadata()

public PdfXmpMetadata()

Constructor for PdfXmpMetadata.


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

PdfXmpMetadata(IDocument document)

public PdfXmpMetadata(IDocument document)

Initializes new PdfXmpMetadata object on base of the document .

Parameters:

ParameterTypeDescription
documentIDocumentPdf document.

registerNamespaceURI(String prefix, String namespaceURI)

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:

ParameterTypeDescription
prefixjava.lang.StringThe prefix.
namespaceURIjava.lang.StringThe namespace URI.

getNamespaceURIByPrefix(String prefix)

public String getNamespaceURIByPrefix(String prefix)

Gets namespace URI by prefix.


PdfXmpMetadata xmp = new PdfXmpMetadata("input.pdf");
 System.out.println(xmp.getNamespaceURIByPrefix("xmp"));

Parameters:

ParameterTypeDescription
prefixjava.lang.StringThe prefix.

Returns: java.lang.String - Namespace URI.

getPrefixByNamespaceURI(String namespaceURI)

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:

ParameterTypeDescription
namespaceURIjava.lang.StringNamespace URI.

Returns: java.lang.String - The prefix value.

addItem(int key, XmpValue value)

public void addItem(int key, 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:

ParameterTypeDescription
keyintThe key name.
valueXmpValueValue which will be added.

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

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

Adds extension field into metadata.

Parameters:

ParameterTypeDescription
xmpPdfAExtensionObjectXmpPdfAExtensionObjectThe pdf extension object to add.
namespacePrefixjava.lang.StringThe prefix of schema.
namespaceUrijava.lang.StringThe namespace uri of schema.
schemaDescriptionjava.lang.StringThe optional description of schema.

clear()

public void clear()

Removes all elements from the object.


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

removeItemByKey(int key)

public void removeItemByKey(int key)

Removes element with specified key.


PdfXmpMetadata xmp = new PdfXmpMetadata();
 xmp.bindPdf("input.pdf");
 xmp.remove(DefaultMetadataProperties.Nickname);

Parameters:

ParameterTypeDescription
keyintKey of the element which will be deleted.

addItem(String key, XmpValue value)

public void addItem(String key, XmpValue value)

Adds new element to the dictionary object.


PdfXmpMetadata xmp = new PdfXmpMetadata();
 xmp.bindPdf("input.pdf");
 xmp.add("xmp:Nickname", "Nickname1");

Parameters:

ParameterTypeDescription
keyjava.lang.StringKey of new element.
valueXmpValueValue of the element.

addItem(String key, Object value)

public void addItem(String key, Object value)

Adds new element to the dictionary object.

Parameters:

ParameterTypeDescription
keyjava.lang.StringKey of new element.
valuejava.lang.ObjectValue of the element.

contains(String key)

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:

ParameterTypeDescription
keyjava.lang.StringKey which will be checked.

Returns: boolean - True - if the dictionary contains the specified key; otherwise, false.

contains(int property)

public boolean contains(int property)

Checks if dictionary contains the specified property.

Parameters:

ParameterTypeDescription
propertyintProperty which will be checked.

Returns: boolean - True - if the dictionary contains the specified property; otherwise, false.

iterator()

public System.Collections.Generic.IGenericEnumerator<System.Collections.Generic.KeyValuePair<String,XmpValue>> iterator()

Gets enumerator object of the dictionary.

Returns: com.aspose.ms.System.Collections.Generic.IGenericEnumerator<com.aspose.ms.System.Collections.Generic.KeyValuePair<java.lang.String,com.aspose.pdf.XmpValue» - The enumerator object.

getKeys()

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

Gets keys from the dictionary.

Returns: com.aspose.ms.System.Collections.Generic.IGenericCollection<java.lang.String> - ICollection element

removeItemByKey(String key)

public boolean removeItemByKey(String key)

Removes key from the dictionary.


PdfXmpMetadata xmp = new PdfXmpMetadata();
 xmp.bindPdf("input.pdf");
 xmp.remove("xmp:Nickname");

Parameters:

ParameterTypeDescription
keyjava.lang.StringKey which will be removed.

Returns: boolean - True - if key removed; otherwise, false.

getExtensionFields()

public Hashtable<String,XmpPdfAExtensionSchema> getExtensionFields()

Gets the dictionary of extension fields.

Returns: java.util.Hashtable<java.lang.String,com.aspose.pdf.XmpPdfAExtensionSchema> - Hashtable object

getValues()

public System.Collections.Generic.IGenericCollection<XmpValue> getValues()

Gets the collection of values in dictionary.

Returns: com.aspose.ms.System.Collections.Generic.IGenericCollection<com.aspose.pdf.XmpValue> - ICollection object

get_Item(String key)

public 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"));

Parameters:

ParameterTypeDescription
keyjava.lang.StringThe key name to get.

Returns: XmpValue - Object by key

set_Item(String key, XmpValue value)

public void set_Item(String key, XmpValue value)

Sets value by key.


PdfXmpMetadata pxm = new PdfXmpMetadata();
 pxm.bindPdf("PdfFile.pdf");
 System.out.println(pxm.get_Item("xmp:Nickname"));

Parameters:

ParameterTypeDescription
keyjava.lang.StringThe key name to set.
valueXmpValueThe value to set.

isFixedSize()

public boolean isFixedSize()

Returns true is collection has fixed size.

Returns: boolean - boolean value

isReadOnly()

public boolean isReadOnly()

Returns true if collection is read-only.

Returns: boolean - boolean value

copyToTArray(System.Collections.Generic.KeyValuePair<String,XmpValue>[] array, int index)

public void copyToTArray(System.Collections.Generic.KeyValuePair<String,XmpValue>[] array, int index)

Copy metadata into array.

Parameters:

ParameterTypeDescription
arraycom.aspose.ms.System.Collections.Generic.KeyValuePair<java.lang.String,com.aspose.pdf.XmpValue>[]The destination array.
indexintThe starting index.

size()

public int size()

Gets count if items in the collection.

Returns: int - 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 - boolean value

getSyncRoot()

public Object getSyncRoot()

Gets synchroniztion object of the collection.

Returns: java.lang.Object - Object element

iteratorIt()

public System.Collections.IEnumerator iteratorIt()

Gets enumerator object of the collection.

Returns: com.aspose.ms.System.Collections.IEnumerator - IEnumerator object

iterator_Rename_Namesake()

public System.Collections.IEnumerator iterator_Rename_Namesake()

Returns: com.aspose.ms.System.Collections.IEnumerator

getByDefaultMetadataProperties(int key)

public 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:

ParameterTypeDescription
keyintKey of the value.

Returns: XmpValue - Value from XMP metadata.

setByDefaultMetadataProperties(int key, XmpValue value)

public void setByDefaultMetadataProperties(int key, 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:

ParameterTypeDescription
keyintKey of the DefaultMetadataProperties value.
valueXmpValueObject.

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: byte[] - The bytes of the XmpMetadata.

getXmpMetadata(String name)

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:

ParameterTypeDescription
namejava.lang.StringMetadata name.

Returns: byte[] - Bytes of metadata.

containsKey(String key)

public boolean containsKey(String key)

Determines does this dictionary contasins specified key.

Parameters:

ParameterTypeDescription
keyjava.lang.StringKey to search in the dictionary.

Returns: boolean - true if key is found.

tryGetValue(String key, Object[] value)

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

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

Parameters:

ParameterTypeDescription
keyjava.lang.StringKey to search in the dictionary.
valuejava.lang.Object[]Retreived value.

Returns: boolean - true if key was found.

addItem(System.Collections.Generic.KeyValuePair<String,XmpValue> item)

public void addItem(System.Collections.Generic.KeyValuePair<String,XmpValue> item)

Adds pair with key and value into the dictionary.

Parameters:

ParameterTypeDescription
itemcom.aspose.ms.System.Collections.Generic.KeyValuePair<java.lang.String,com.aspose.pdf.XmpValue>Item to be added.

containsItem(System.Collections.Generic.KeyValuePair<String,XmpValue> item)

public boolean containsItem(System.Collections.Generic.KeyValuePair<String,XmpValue> item)

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

Parameters:

ParameterTypeDescription
itemcom.aspose.ms.System.Collections.Generic.KeyValuePair<java.lang.String,com.aspose.pdf.XmpValue>Key-value pair.

Returns: boolean - true if this pauir was found.

removeItem(System.Collections.Generic.KeyValuePair<String,XmpValue> item)

public boolean removeItem(System.Collections.Generic.KeyValuePair<String,XmpValue> item)

Removes key/value pair from the collection.

Parameters:

ParameterTypeDescription
itemcom.aspose.ms.System.Collections.Generic.KeyValuePair<java.lang.String,com.aspose.pdf.XmpValue>Key/value pair to be removed.

Returns: boolean - true if pair was found and removed.