Skip to main content
All docs
V26.1
  • XmpRawAccess Class

    The XMP metadata’s raw XML nodes.

    Namespace: DevExpress.Docs.Pdf

    Assembly: DevExpress.Docs.Pdf.v26.1.dll

    NuGet Package: DevExpress.Docs.Pdf

    Declaration

    public sealed class XmpRawAccess

    The following members return XmpRawAccess objects:

    Remarks

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

    Inheritance

    Object
    XmpRawAccess
    See Also