Document metadata

Docotic.Pdf Library Help > Samples > Metadata > Document metadata

This sample shows how to change metadata of a PDF document (properties such as "Author", "Title") using PdfInfo class.

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

CopyC#
using System.Diagnostics;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class Metadata
    {
        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.

            PdfDocument pdf = new PdfDocument();

            pdf.Info.Author = "Sample Browser application";
            pdf.Info.Subject = "Document metadata";
            pdf.Info.Title = "Custom title goes here";
            pdf.Info.Keywords = "pdf, Docotic.Pdf";

            PdfPage page = pdf.Pages[0];
            page.Canvas.DrawString(10, 50, "Check document properties");

            string pathToFile = "Metadata.pdf";
            pdf.Save(pathToFile);
            pdf.Dispose();

            Process.Start(pathToFile);
        }
    }
}
CopyVB.NET
Imports System.Diagnostics

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class Metadata
        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.


            Dim pdf As New PdfDocument()

            pdf.Info.Author = "Sample Browser application"
            pdf.Info.Subject = "Document metadata"
            pdf.Info.Title = "Custom title goes here"
            pdf.Info.Keywords = "pdf, Docotic.Pdf"

            Dim page As PdfPage = pdf.Pages(0)
            page.Canvas.DrawString(10, 50, "Check document properties")

            Dim pathToFile As String = "Metadata.pdf"
            pdf.Save(pathToFile)
            pdf.Dispose()

            Process.Start(pathToFile)
        End Sub
    End Class
End Namespace