XmpDocument.RegisterNamespace(String, String) Method
Registers the namespace in the XMP packet.
Namespace: DevExpress.Pdf.Xmp
Assembly: DevExpress.Pdf.v21.1.Core.dll
NuGet Package: DevExpress.Pdf.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
namespaceUri | String | The namespace URI. |
preferredPrefix | String | The preferred prefix. |
Returns
Type | Description |
---|---|
Boolean | true, if the namespace is registered successfully; otherwise, false. |
Remarks
When you add a new node to the packet, you can use an XmpName class object or a string to specify the node name. In the latter case, make sure that the specified prefix is registered. You can call the RegisterNamespace method to register the prefix.
The code sample below registers the prefix and adds a new node to the packet:
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
// Load a document:
pdfDocumentProcessor.LoadDocument("Documents//Invoice_blank.pdf");
PdfDocument document = pdfDocumentProcessor.Document;
XmpDocument generatedMetadata = new XmpDocument();
// Register namespaces:
document.RegisterNamespace("http://ns.adobe.com/xap/1.0/", "xmp");
// Add items with "xmp" prefix:
XmpArray array = document.CreateArray("xmp:Identifier", XmpArrayType.Unordered);
array.Add("identifier1");
array.Add("identifier2");
array.Add("identifier3");
document.CreateSimpleValue("xmp:Label", "Demo");
// Embed generated metadata to the document:
document.SetMetadata(generatedMetadata);
// Save the result:
pdfDocumentProcessor.SaveDocument("Invoice_new.pdf");
}
See Also