Get and set document properties in C# and VB.NET

With PDF .Net, you can get and set PDF files document properties (document information) in your C# or VB.NET application.

The following example shows how you can set PDF .Net.Info of an existing PDF document.

Complete code

using System;
using System.IO;
using SautinSoft;
using SautinSoft.Pdf;
using SautinSoft.Pdf.Content;

namespace Sample
{
    class Sample
    {
        /// <summary>
        /// Get and set document properties.
        /// </summary>
        /// <remarks>
        /// Details: http://sautinsoft/products/pdf/help/net/developer-guide/document-properties-pdf.php
        /// </remarks>
        static void Main(string[] args)
        {
            string pdfFile = Path.GetFullPath(@"..\..\..\simple text.pdf");

            using (var document = PdfDocument.Load(pdfFile))
            {
                // Get document properties.
                var info = document.Info;

                // Update document properties.
                info.Title = "My Title";
                info.Author = "My Author";
                info.Subject = "My Subject";
                info.Creator = "My Application";

                // Update producer and date information, and disable their overriding.
                info.Producer = "My Producer";
                info.CreationDate = new DateTime(2023, 1, 1, 12, 0, 0);
                info.ModificationDate = new DateTime(2023, 1, 1, 12, 0, 0);
                document.SaveOptions.UpdateProducerInformation = false;
                document.SaveOptions.UpdateDateInformation = false;

                document.Save("Document Properties.pdf");
            }
        }
    }
}

Download


If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below:



Questions and suggestions from you are always welcome!

We are developing .Net components since 2002. We know PDF, DOCX, RTF, HTML, XLSX and Images formats. If you need any assistance with creating, modifying or converting documents in various formats, we can help you. We will write any code example for you absolutely free.