XmpMetadata Class
Contains PDF document XMP metadata.
Namespace: DevExpress.Docs.Pdf
Assembly: DevExpress.Docs.Pdf.v26.1.dll
Declaration
Related API Members
The following members return XmpMetadata objects:
Remarks
Adobe Extensible Metadata Platform (XMP) is an XML-based ISO metadata standard created by Adobe Systems Inc. It defines the data structure, serialization model, and basic metadata properties for a unified metadata package that can be embedded in different media formats.
You can load metadata from a stream or string, edit existing metadata, or generate a new XMP data model.
Load XMP Metadata from a File or a String
Use one of the following methods to load XMP metadata:
The following code snippet loads XMP metadata from a file and embeds it into a PDF document:
using (PdfDocument pdfDocument =
new PdfDocument(File.OpenRead(@"document_001.pdf"))) {
using (FileStream xmlStream = new FileStream("Documents//metadata.xml", FileMode.Open, FileAccess.Read))
{
pdfDocument.Metadata.Xmp = XmpMetadata.FromStream(xmlStream);
}
}
Use XMP Schemas
An XMP schema, or namespace, is a set of metadata properties. Each schema is identified by a unique namespace URI and can contain any number of properties. The XMP specification defines predefined schemas, including standard general-purpose namespaces and namespaces specialized for Adobe applications.
PDF Document API supports the following predefined XMP namespaces:
| Namespace | Description | Credentials | Class |
|---|---|---|---|
| Basic XMP | Contains basic description information. | Namespace URI: http://ns.adobe.com/xap/1.0/ Prefix: xmp |
XmpBasicSchema |
| Adobe PDF | Specifies properties used in Adobe PDF documents. | Namespace URI: http://ns.adobe.com/pdf/1.3/ Prefix: pdf |
XmpPdfSchema |
| PDF/A | Defines a document’s PDF/A conformance level and version. | Namespace URI: https://www.aiim.org/pdfa/ns/id Prefix: pdfaid |
XmpPdfASchema |
| PDF/UA | Defines a document’s PDF/UA conformance level and version. | Namespace URI: https://www.aiim.org/pdfua/ns/id Prefix: pdfua |
XmpPdfUASchema |
| Dublin Core | Contains information defined in the Dublin Core Metadata Set, created by the Dublin Core Metadata Initiative (DCMI). | Namespace URI: http://purl.org/dc/elements/1.1/_ Prefix: dc |
XmpDublinCoreSchema |
| Rights Management | Contains information regarding the legal restrictions associated with a PDF document. | Namespace URI: http://ns.adobe.com/xap/1.0/rights/ Prefix: xmpRights |
XmpRightsManagementSchema |
The following code snippet creates the Rights Management schema and embeds it into a PDF document:
using DevExpress.Docs.Pdf;
using System.IO;
using (PdfDocument pdfDocument =
new PdfDocument(File.OpenRead(@"document_001.pdf"))) {
// Create a new XMP packet:
XmpMetadata metadata = new XmpMetadata();
XmpRightsManagementSchema rightsManagementSchema =
metadata.XmpRightsManagementSchema;
rightsManagementSchema.Certificate = new XmpString("https://www.devexpress.com/");
rightsManagementSchema.Owner.Add(new XmpString("DevExpress"));
rightsManagementSchema.Marked = true;
rightsManagementSchema.WebStatement = new XmpString("https://www.devexpress.com/support/eulas/");
rightsManagementSchema.UsageTerms.Add("EN-US", "Copyright(C) 2026 DevExpress.All Rights Reserved.");
// Embed metadata in the document:
pdfDocument.Metadata.Xmp = metadata;
}
Create Custom XMP Schemas
Create a new XmpCustomSchema and set it as the DocumentMetadata.Xmp property value. Use XmpCustomSchema properties and methods to manage custom metadata properties.
The following code snippet creates a custom XMP schema with the “http://www.example.com/custom/1.0/“ namespace URI and adds custom properties to this schema:
using DevExpress.Docs.Pdf;
using System.IO;
using (PdfDocument pdfDocument =
new PdfDocument(File.OpenRead(@"document_001.pdf"))) {
XmpMetadata metadata = new XmpMetadata();
XmpCustomSchema customSchema = metadata.CustomSchema;
metadata.RegisterNamespace("http://www.example.com/custom/1.0/", "dx");
customSchema["Team"] = "Office";
customSchema["Checked"] = "true";
customSchema["Project"] = "PDF Document API";
// Embed metadata in the document:
pdfDocument.Metadata.Xmp = metadata;
}
Manage Metadata Nodes
Use the XmpMetadata.RawData property to obtain XMP metadata as an XmpRawAccess object. This object allows you to access XMP metadata properties as raw XML nodes. You can use the XmpRawAccess methods to get, set, or remove property values. Identify properties as “URI:name” or “prefix:name”.
Obtain Property Values
Call the XmpRawAccess.GetString(String) method to obtain a property value. Identify a property as “URI:name” or “prefix:name”.
The following code snippet obtains “Identifier” and “Rating” property values from the Basic XMP namespace:
using DevExpress.Docs.Pdf;
using System.IO;
using (PdfDocument pdfDocument =
new PdfDocument(File.OpenRead(@"document_001.pdf"))) {
using (FileStream xmlStream = new FileStream("Documents//metadata.xml", FileMode.Open, FileAccess.Read))
{
pdfDocument.Metadata.Xmp = XmpMetadata.FromStream(xmlStream);
string identifier = pdfDocument.Metadata.Xmp.RawData.GetString("xmp:Identifier");
string rating = pdfDocument.Metadata.Xmp.RawData.GetString("xmp:Rating");
}
}
Set Property Values
Use the XmpRawAccess.SetString(String, String) method to set a property value. Identify the property as “URI:name” or “prefix:name”.
Make sure the property is defined in the specified XMP namespace and supports string values. Call the XmpMetadata.RegisterNamespace(String, String) method to register a custom namespace if you want to use properties that are not defined in the predefined XMP namespaces.
The following code snippet sets “Label” and “Creator Tool” property values in the Basic XMP namespace:
using DevExpress.Docs.Pdf;
using System.IO;
using (PdfDocument pdfDocument =
new PdfDocument(File.OpenRead(@"document_001.pdf"))) {
using (FileStream xmlStream = new FileStream("Documents//metadata.xml", FileMode.Open, FileAccess.Read))
{
pdfDocument.Metadata.Xmp = XmpMetadata.FromStream(xmlStream);
pdfDocument.Metadata.Xmp.RawData.SetString("xmp:Label", "Updated Label");
pdfDocument.Metadata.Xmp.RawData.SetString("xmp:CreatorTool", "Updated Creator Tool");
}
}
Remove Properties
Call the XmpRawAccess.Remove(String) method to remove a property. Identify properties as “URI:name” or “prefix:name”. .
The following code snippet removes “Label” and “Creator Tool” properties from the Basic XMP namespace:
using DevExpress.Docs.Pdf;
using System.IO;
using (PdfDocument pdfDocument =
new PdfDocument(File.OpenRead(@"document_001.pdf"))) {
using (FileStream xmlStream = new FileStream("Documents//metadata.xml", FileMode.Open, FileAccess.Read))
{
pdfDocument.Metadata.Xmp = XmpMetadata.FromStream(xmlStream);
pdfDocument.Metadata.Xmp.RawData.Remove("xmp:Label");
pdfDocument.Metadata.Xmp.RawData.Remove("xmp:CreatorTool");
}
}