Back to Devexpress

XmpName Class

officefileapi-devexpress-dot-pdf-dot-xmp-a9ede8c6.md

latest3.6 KB
Original Source

XmpName Class

The XMP packet node name in the prefix:local format.

Namespace : DevExpress.Pdf.Xmp

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

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public class XmpName :
    IEquatable<XmpName>
vb
Public Class XmpName
    Implements IEquatable(Of XmpName)

The following members return XmpName objects:

Remarks

When you add a new node to the packet, use the XmpName object to specify the node name. Call the XmpName.Get(String, String) method to generate a node name and register the prefix.

The code sample below sues the XmpName.Get(String, String) method to generate a name for a new structure node:

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 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 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

Implements

IEquatable<XmpName>

Inheritance

Object XmpName

See Also

XmpName Members

DevExpress.Pdf.Xmp Namespace