Docotic.Pdf Library Help > Samples > Metadata > Set custom XMP metadata properties

This sample shows how to change custom (application-defined) metadata properties of a PDF document. These properties are displayed in the Additional Metadata view and on the Custom tab of Document Properties dialog of Adobe Acrobat Professional.

Docotic.Pdf can be used to read and set strings, arrays of different types and structures as custom properties. To access custom metadata properties of a PDF document, use PdfDocument.Metadata.Custom property.

using System.Diagnostics;
using System.Drawing;
using System.IO;

using BitMiracle.Docotic.Pdf;

namespace BitMiracle.Docotic.Pdf.Samples
    public static class SetCustomXmpProperties
        public static void Main()
            // NOTE: 
            // When used in trial mode, the library imposes some restrictions.
            // Please visit
            // for more information.

            using (PdfDocument pdf = new PdfDocument())
                XmpSchema custom = pdf.Metadata.Custom;

                // add simple string property
                custom.Properties.Add("stringProperty", "string value");

                // add simple array property
                XmpArray array = new XmpArray(XmpArrayType.Ordered);
                for (int i = 0; i < 5; i++)
                    array.Values.Add(new XmpString(i.ToString()));
                custom.Properties.Add("arrayProperty", array);

                // array array with language alternatives
                XmpArray languageArray = new XmpArray(XmpArrayType.Alternative);
                languageArray.Values.Add(new XmpLanguageAlternative("x-default", "I'm Feeling Lucky"));
                languageArray.Values.Add(new XmpLanguageAlternative("fr-fr", "J'ai de la chance"));
                custom.Properties.Add("arrayWithAlternatives", languageArray);

                // add string properties with qualifiers
                XmpString author1 = new XmpString("First Author");
                author1.Qualifiers.Add("role", "main author");
                custom.Properties.Add("anotherStringProperty", author1);

                XmpString author2 = new XmpString("Second Author");
                author2.Qualifiers.Add("role", "co-author");
                custom.Properties.Add("yetAnotherStringProperty", author2);

                // add array with qualified string values
                XmpArray authors = new XmpArray(XmpArrayType.Unordered);
                custom.Properties.Add("arrayWithQualifiedStrings", authors);

                // add structure
                XmpStructure structure = new XmpStructure("struct", "");
                structure.Properties.Add("string", "string in a structure");
                structure.Properties.Add("array", authors);
                structure.Properties.Add("arrayWithAlternatives", languageArray);
                custom.Properties.Add("structureProperty", structure);

                string pathToFile = "SetCustomXmpProperties.pdf";

Imports System.Diagnostics
Imports System.Drawing
Imports System.IO

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class SetCustomXmpProperties
        Public Shared Sub Main()
            ' NOTE: 
            ' When used in trial mode, the library imposes some restrictions.
            ' Please visit
            ' for more information.

            Using pdf As New PdfDocument()
                Dim custom As XmpSchema = pdf.Metadata.Custom

                ' add simple string property
                custom.Properties.Add("stringProperty", "string value")

                ' add simple array property
                Dim array As New XmpArray(XmpArrayType.Ordered)
                For i As Integer = 0 To 4
                    array.Values.Add(New XmpString(i.ToString()))
                custom.Properties.Add("arrayProperty", array)

                ' array array with language alternatives
                Dim languageArray As New XmpArray(XmpArrayType.Alternative)
                languageArray.Values.Add(New XmpLanguageAlternative("x-default", "I'm Feeling Lucky"))
                languageArray.Values.Add(New XmpLanguageAlternative("fr-fr", "J'ai de la chance"))
                custom.Properties.Add("arrayWithAlternatives", languageArray)

                ' add string properties with qualifiers
                Dim author1 As New XmpString("First Author")
                author1.Qualifiers.Add("role", "main author")
                custom.Properties.Add("anotherStringProperty", author1)

                Dim author2 As New XmpString("Second Author")
                author2.Qualifiers.Add("role", "co-author")
                custom.Properties.Add("yetAnotherStringProperty", author2)

                ' add array with qualified string values
                Dim authors As New XmpArray(XmpArrayType.Unordered)
                custom.Properties.Add("arrayWithQualifiedStrings", authors)

                ' add structure
                Dim struct As New XmpStructure("struct", "")
                struct.Properties.Add("string", "string in a structure")
                struct.Properties.Add("array", authors)
                struct.Properties.Add("arrayWithAlternatives", languageArray)
                custom.Properties.Add("structureProperty", struct)

                Dim pathToFile As String = "SetCustomXmpProperties.pdf"

            End Using
        End Sub
    End Class
End Namespace