Back to Devexpress

XmpArray Class

officefileapi-devexpress-dot-pdf-dot-xmp-66e650f2.md

latest6.9 KB
Original Source

XmpArray Class

An XMP metadata node with an array value.

Namespace : DevExpress.Pdf.Xmp

Assembly : DevExpress.Pdf.v25.2.Core.dll

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public class XmpArray :
    XmpValueNode
vb
Public Class XmpArray
    Inherits XmpValueNode

The following members return XmpArray objects:

Show 26 links

Remarks

An array is a container for items of any available value type, including a nested array and structure.

Example

The code sample below edits document metadata:

View Example: How to Embed XMP Metadata to the PDF Document

csharp
using DevExpress.Pdf;
using DevExpress.Pdf.Xmp;
//...

using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
    // Load a document
    pdfDocumentProcessor.LoadDocument("Documents//Invoice.pdf");
    PdfDocument document = pdfDocumentProcessor.Document;

    // Retrieve metadata:
    XmpDocument metadata = XmpDocument.FromString(document.Metadata.Data);

    // Add items to the Creator array:
    XmpArray creators = metadata.GetArray("dc:creator");
    if (creators != null)
    {
        creators.Add("PDF Document API");
        creators.Add("Office File API");
    }

    // Change the CreatorTool node value:
    XmpSimpleNode creatorTool = metadata.GetSimpleValue("xmp:CreatorTool");
    creatorTool.SetValue("PDF Document API");

    // Add MaxPageSize structure:
    XmpName structureName = XmpName.Get("MaxPageSize", "http://ns.adobe.com/xap/1.0/t/pg/");
    XmpStructure dimensions = metadata.CreateStructure(structureName);
    metadata.RegisterNamespace("http://ns.adobe.com/xap/1.0/sType/Dimensions#", "stDim");
    dimensions.Add("stDim:h", 11);
    dimensions.Add("stDim:w", 8.5f);
    dimensions.Add("stDim:Unit", "inch");

    // Embed modified metadata in the document:
    document.SetMetadata(metadata);

    // Save the result:
    pdfDocumentProcessor.SaveDocument("Invoice_Upd.pdf");
}
vb
Imports DevExpress.Pdf
Imports DevExpress.Pdf.Xmp
'...

Using pdfDocumentProcessor As New PdfDocumentProcessor()
    ' Load a document
    pdfDocumentProcessor.LoadDocument("Documents//Invoice.pdf")
    Dim document As PdfDocument = pdfDocumentProcessor.Document

    ' Retrieve metadata:
    Dim metadata As XmpDocument = XmpDocument.FromString(document.Metadata.Data)

    ' Add items to the Creator array:
    Dim creators As XmpArray = metadata.GetArray("dc:creator")
    If creators IsNot Nothing Then
        creators.Add("PDF Document API")
        creators.Add("Office File API")
    End If

    ' Change the CreatorTool node value:
    Dim creatorTool As XmpSimpleNode = metadata.GetSimpleValue("xmp:CreatorTool")
    creatorTool.SetValue("PDF Document API")

    ' Add MaxPageSize structure:
    Dim structureName As XmpName = XmpName.Get("MaxPageSize", "http://ns.adobe.com/xap/1.0/t/pg/")
    Dim dimensions As XmpStructure = metadata.CreateStructure(structureName)
    metadata.RegisterNamespace("http://ns.adobe.com/xap/1.0/sType/Dimensions#", "stDim")
    dimensions.Add("stDim:h", 11)
    dimensions.Add("stDim:w", 8.5F)
    dimensions.Add("stDim:Unit", "inch")

    ' Embed modified metadata in the document:
    document.SetMetadata(metadata)

    ' Save the result:
    pdfDocumentProcessor.SaveDocument("Invoice_Upd.pdf")
End Using

Inheritance

Object XmpNode XmpValueNode XmpArray

See Also

XmpArray Members

DevExpress.Pdf.Xmp Namespace