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
Constructor | Description |
---|---|
PdfXmpMetadata() | Constructor for PdfXmpMetadata. |
PdfXmpMetadata(IDocument document) | Initializes new PdfXmpMetadata object on base of the document . |
Methods
Method | Description |
---|---|
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:
Parameter | Type | Description |
---|---|---|
document | IDocument | Pdf 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:
Parameter | Type | Description |
---|---|---|
prefix | java.lang.String | The prefix. |
namespaceURI | java.lang.String | The 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:
Parameter | Type | Description |
---|---|---|
prefix | java.lang.String | The 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:
Parameter | Type | Description |
---|---|---|
namespaceURI | java.lang.String | Namespace 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:
Parameter | Type | Description |
---|---|---|
key | int | The key name. |
value | XmpValue | Value 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:
Parameter | Type | Description |
---|---|---|
xmpPdfAExtensionObject | XmpPdfAExtensionObject | The pdf extension object to add. |
namespacePrefix | java.lang.String | The prefix of schema. |
namespaceUri | java.lang.String | The namespace uri of schema. |
schemaDescription | java.lang.String | 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();
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:
Parameter | Type | Description |
---|---|---|
key | int | Key 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:
Parameter | Type | Description |
---|---|---|
key | java.lang.String | Key of new element. |
value | XmpValue | Value of the element. |
addItem(String key, Object value)
public void addItem(String key, Object value)
Adds new element to the dictionary object.
Parameters:
Parameter | Type | Description |
---|---|---|
key | java.lang.String | Key of new element. |
value | java.lang.Object | Value 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:
Parameter | Type | Description |
---|---|---|
key | java.lang.String | Key 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:
Parameter | Type | Description |
---|---|---|
property | int | Property 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:
Parameter | Type | Description |
---|---|---|
key | java.lang.String | Key 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:
Parameter | Type | Description |
---|---|---|
key | java.lang.String | The 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:
Parameter | Type | Description |
---|---|---|
key | java.lang.String | The key name to set. |
value | XmpValue | The 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:
Parameter | Type | Description |
---|---|---|
array | com.aspose.ms.System.Collections.Generic.KeyValuePair<java.lang.String,com.aspose.pdf.XmpValue>[] | The destination array. |
index | int | The 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:
Parameter | Type | Description |
---|---|---|
key | int | Key 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:
Parameter | Type | Description |
---|---|---|
key | int | Key of the DefaultMetadataProperties value. |
value | XmpValue | Object. |
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:
Parameter | Type | Description |
---|---|---|
name | java.lang.String | Metadata name. |
Returns: byte[] - Bytes of metadata.
containsKey(String key)
public boolean containsKey(String key)
Determines does this dictionary contasins specified key.
Parameters:
Parameter | Type | Description |
---|---|---|
key | java.lang.String | Key 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:
Parameter | Type | Description |
---|---|---|
key | java.lang.String | Key to search in the dictionary. |
value | java.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:
Parameter | Type | Description |
---|---|---|
item | com.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:
Parameter | Type | Description |
---|---|---|
item | com.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:
Parameter | Type | Description |
---|---|---|
item | com.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.