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

This sample shows how to change XMP metadata properties (like Dublin Core properties) of a PDF document. These properties are displayed in the Additional Metadata view of Document Properties dialog of Adobe Acrobat Professional.

Docotic.Pdf can be used to read and set XMP metadata properties defined in any schema. For some schemas (so called "well-known schemas") there are convenience properties added to the API of the library.

To access metadata properties of a PDF document, use PdfDocument.Metadata property.

PdfDocument.Metadata also contains convenience properties for custom (application-defined) properties, Adobe PDF file properties, XMP Core / XMP Basic properties, Dublin Core properties, Media Management properties and Rights Management properties.

C#
using System.Diagnostics;
using System.Drawing;
using System.IO;

using BitMiracle.Docotic.Pdf;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class SetXmpProperties
    {
        public static void Main()
        {
            // NOTE: 
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            using (PdfDocument pdf = new PdfDocument())
            {
                pdf.Metadata.DublinCore.Creators = new XmpArray(XmpArrayType.Ordered);
                pdf.Metadata.DublinCore.Creators.Values.Add(new XmpString("me"));
                pdf.Metadata.DublinCore.Creators.Values.Add(new XmpString("Docotic.Pdf"));

                pdf.Metadata.DublinCore.Format = new XmpString("application/pdf");

                pdf.Metadata.Pdf.Producer = new XmpString("me too!");

                string pathToFile = "SetXmpProperties.pdf";
                pdf.Save(pathToFile);
                Process.Start(pathToFile);
            }
        }
    }
}
VB
Imports System.Diagnostics
Imports System.Drawing
Imports System.IO

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class SetXmpProperties
        Public Shared Sub Main()
            ' NOTE: 
            ' When used in trial mode, the library imposes some restrictions.
            ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            ' for more information.

            Using pdf As New PdfDocument()
                pdf.Metadata.DublinCore.Creators = New XmpArray(XmpArrayType.Ordered)
                pdf.Metadata.DublinCore.Creators.Values.Add(New XmpString("me"))
                pdf.Metadata.DublinCore.Creators.Values.Add(New XmpString("Docotic.Pdf"))

                pdf.Metadata.DublinCore.Format = New XmpString("application/pdf")

                pdf.Metadata.Pdf.Producer = New XmpString("me too!")

                Dim pathToFile As String = "SetXmpProperties.pdf"
                pdf.Save(pathToFile)
                Process.Start(pathToFile)
            End Using
        End Sub
    End Class
End Namespace