Get PDF Properties in C#, VB.NET

PDF properties display a summary of basic information about one document, such as the author, subject, created time, security settings and etc. By viewing the properties of a PDF document, users are able to learn about PDF file information as soon as possible. In this article, I’ll introduce how to get properties of a PDF file using Spire.PDF in C# and VB.NET.

In fact, it is very easy to get the specific information of a PDF file by using Information property of the PdfDoucment object. Once the DocumentInformation object is retrieved, you can get the values of the individual properties.

Properties of Sample File:

Get PDF Properties in C#, VB.NET

Code Snippet:

Step 1: Create a new PDF document and load the sample file.

PdfDocument pdf = new PdfDocument("Sample.pdf");

Step 2: Get the document properties and display them on console.

Console.WriteLine("Title: " + pdf.DocumentInformation.Title);
Console.WriteLine("Author: " + pdf.DocumentInformation.Author);
Console.WriteLine("Subject: " + pdf.DocumentInformation.Subject);
Console.WriteLine("Keywords: " + pdf.DocumentInformation.Keywords);
Console.WriteLine("Created: " + pdf.DocumentInformation.CreationDate);
Console.WriteLine("Modified: " + pdf.DocumentInformation.ModificationDate);
Console.WriteLine("Creator: " + pdf.DocumentInformation.Creator);
Console.WriteLine("PDF Producer: " + pdf.DocumentInformation.Producer);

Result in Console:

Get PDF Properties in C#, VB.NET

Full Code:

[C#]
PdfDocument pdf = new PdfDocument("Sample.pdf");
Console.WriteLine("Title: " + pdf.DocumentInformation.Title);
Console.WriteLine("Author: " + pdf.DocumentInformation.Author);
Console.WriteLine("Subject: " + pdf.DocumentInformation.Subject);
Console.WriteLine("Keywords: " + pdf.DocumentInformation.Keywords);
Console.WriteLine("");
Console.WriteLine("Created: " + pdf.DocumentInformation.CreationDate);
Console.WriteLine("Modified: " + pdf.DocumentInformation.ModificationDate);
Console.WriteLine("Creator: " + pdf.DocumentInformation.Creator);
Console.WriteLine("");
Console.WriteLine("PDF Producer: " + pdf.DocumentInformation.Producer);
Console.ReadKey();
[VB.NET]
Dim pdf As New PdfDocument("Sample.pdf")
Console.WriteLine("Title: " + pdf.DocumentInformation.Title)
Console.WriteLine("Author: " + pdf.DocumentInformation.Author)
Console.WriteLine("Subject: " + pdf.DocumentInformation.Subject)
Console.WriteLine("Keywords: " + pdf.DocumentInformation.Keywords)
Console.WriteLine("")
Console.WriteLine("Created: " + pdf.DocumentInformation.CreationDate)
Console.WriteLine("Modified: " + pdf.DocumentInformation.ModificationDate)
Console.WriteLine("Creator: " + pdf.DocumentInformation.Creator)
Console.WriteLine("")
Console.WriteLine("PDF Producer: " + pdf.DocumentInformation.Producer)
Console.ReadKey()