XmpPackage
Leave feedback
On this page
Inheritance: java.lang.Object, com.groupdocs.metadata.core.MetadataPackage, com.groupdocs.metadata.core.CustomPackage, com.groupdocs.metadata.core.XmpMetadataContainer
public class XmpPackage extends XmpMetadataContainer
Represents base abstraction for XMP package.
Learn more
This example demonstrates how to add a custom XMP package to a file of any supported format.
try (Metadata metadata = new Metadata(Constants.InputJpeg)) { IXmp root = (IXmp) metadata.getRootPackage(); XmpPacketWrapper packet = new XmpPacketWrapper(); XmpPackage custom = new XmpPackage(“gd”, “https://groupdocs.com”); custom.set(“gd:Copyright”, “Copyright (C) 2011-2024 GroupDocs. All Rights Reserved.”); custom.set(“gd:CreationDate”, new Date()); custom.set(“gd:Company”, XmpArray.from(new String[]{“Aspose”, “GroupDocs”}, XmpArrayType.Ordered)); packet.addPackage(custom); root.setXmpPackage(packet); metadata.save(Constants.OutputJpeg); }
| Constructor | Description |
|---|---|
| XmpPackage(String prefix, String namespaceUri) | Initializes a new instance of the XmpPackage class. |
| Method | Description |
|---|---|
| getPrefix() | Gets the xmlns prefix. |
| getNamespaceUri() | Gets the namespace URI. |
| getXmlNamespace() | Gets the XML namespace. |
| set(String name, String value) | Sets string property. |
| set(String name, int value) | Sets integer property. |
| set(String name, boolean value) | Sets boolean property. |
| set(String name, Date value) | Sets DateTime property. |
| set(String name, double value) | Sets double property. |
| remove(String name) | Removes the property with the specified name. |
| clear() | Removes all XMP properties. |
| set(String name, XmpValueBase value) | Sets the value inherited from XmpValueBase . |
| set(String name, XmpComplexType value) | Sets the value inherited from XmpComplexType . |
| set(String name, XmpArray value) | Sets the value inherited from XmpArray . |
| getXmpRepresentation() | Converts the XMP value to the XML representation. |
public XmpPackage(String prefix, String namespaceUri)
Initializes a new instance of the XmpPackage class.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| prefix | java.lang.String | XMP prefix, for example dc:title. |
| namespaceUri | java.lang.String | Namespace uri. |
public final String getPrefix()
Gets the xmlns prefix.
Returns: java.lang.String - The prefix.
public final String getNamespaceUri()
Gets the namespace URI.
Returns: java.lang.String - The namespace URI.
public final String getXmlNamespace()
Gets the XML namespace.
Returns: java.lang.String - The XML namespace.
public void set(String name, String value)
Sets string property.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| name | java.lang.String | XMP metadata property name. |
| value | java.lang.String | XMP metadata property value. |
public final void set(String name, int value)
Sets integer property.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| name | java.lang.String | XMP metadata property name. |
| value | int | XMP metadata property value. |
public final void set(String name, boolean value)
Sets boolean property.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| name | java.lang.String | XMP metadata property name. |
| value | boolean | XMP metadata property value. |
public final void set(String name, Date value)
Sets DateTime property.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| name | java.lang.String | XMP metadata property name. |
| value | java.util.Date | XMP metadata property value. |
public final void set(String name, double value)
Sets double property.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| name | java.lang.String | XMP metadata property name. |
| value | double | XMP metadata property value. |
public final boolean remove(String name)
Removes the property with the specified name.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| name | java.lang.String | XMP metadata property name. |
Returns: boolean - True if the specified metadata property is found and removed; otherwise, false.
public final void clear()
Removes all XMP properties.
public final void set(String name, XmpValueBase value)
Sets the value inherited from XmpValueBase .
Parameters:
| Parameter | Type | Description |
|---|---|---|
| name | java.lang.String | XMP metadata property name. |
| value | XmpValueBase | XMP metadata property value. |
public void set(String name, XmpComplexType value)
Sets the value inherited from XmpComplexType .
Parameters:
| Parameter | Type | Description |
|---|---|---|
| name | java.lang.String | XMP metadata property name. |
| value | XmpComplexType | XMP metadata property value. |
public void set(String name, XmpArray value)
Sets the value inherited from XmpArray .
Parameters:
| Parameter | Type | Description |
|---|---|---|
| name | java.lang.String | XMP metadata property name. |
| value | XmpArray | XMP metadata property value. |
public String getXmpRepresentation()
Converts the XMP value to the XML representation.
Returns: java.lang.String - A string representation of the XMP value.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.