officefileapi-devexpress-dot-pdf-dot-xmp-dot-xmpdocument-dot-registernamespace-x28-system-dot-string-system-dot-string-x29.md
Registers the namespace in the XMP packet.
Namespace : DevExpress.Pdf.Xmp
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public bool RegisterNamespace(
string namespaceUri,
string preferredPrefix
)
Public Function RegisterNamespace(
namespaceUri As String,
preferredPrefix As String
) As Boolean
| Name | Type | Description |
|---|---|---|
| namespaceUri | String |
The namespace URI.
| | preferredPrefix | String |
The preferred prefix.
|
| Type | Description |
|---|---|
| Boolean |
true , if the namespace is registered successfully; otherwise, false.
|
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");
}
Using pdfDocumentProcessor As New PdfDocumentProcessor()
' Load a document:
pdfDocumentProcessor.LoadDocument("Documents//Invoice_blank.pdf")
Dim document As PdfDocument = pdfDocumentProcessor.Document
Dim generatedMetadata As New XmpDocument()
' Register namespaces:
document.RegisterNamespace("http://ns.adobe.com/xap/1.0/", "xmp")
' Add items with "xmp" prefix:
Dim array As XmpArray = 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")
End Using
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the RegisterNamespace(String, String) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
pdf-document-api-xmp-example/CS/XmpMetadataExamples/Program.cs#L43
XmpStructure dimensions = editedMetadata.CreateStructure(structureName);
editedMetadata.RegisterNamespace("http://ns.adobe.com/xap/1.0/sType/Dimensions#", "stDim");
dimensions.Add("stDim:h", 11);
pdf-document-api-xmp-example/VB/XmpMetadataExamples/Program.vb#L35
Dim dimensions As XmpStructure = editedMetadata.CreateStructure(structureName)
editedMetadata.RegisterNamespace("http://ns.adobe.com/xap/1.0/sType/Dimensions#", "stDim")
dimensions.Add("stDim:h", 11)
See Also