Articles in this section
Category / Section

How to Read WinForms PDF Properties Using C# and VB.NET?

2 mins read

Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can read the document information of an existing PDF, such as the author, creation date, subject, title, and producer, using C# and VB.NET.

Steps to read PDF properties programmatically:

  1. Create a new C# console application project. Create new console application
  2. Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET Framework application from NuGet.org. Install nuget packages
  3. Include the following namespaces in the Program.cs file.

C#

using Syncfusion.Pdf.Parsing;
using System;

 

VB.NET

Imports Syncfusion.Pdf.Parsing
Imports System

 

  1. Use the following code snippet to read PDF properties.

C#

// Load the PDF document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("DocumentInformation.pdf");
// Read the PDF document information
Console.WriteLine("Author: {0}", loadedDocument.DocumentInformation.Author);
Console.WriteLine("Creation Date: {0}", loadedDocument.DocumentInformation.CreationDate);
Console.WriteLine("Modification Date: {0}", loadedDocument.DocumentInformation.ModificationDate);
Console.WriteLine("Creator: {0}", loadedDocument.DocumentInformation.Creator);
Console.WriteLine("Keywords: {0}", loadedDocument.DocumentInformation.Keywords);
Console.WriteLine("Subject: {0}", loadedDocument.DocumentInformation.Subject);
Console.WriteLine("Title: {0}", loadedDocument.DocumentInformation.Title);
Console.WriteLine("Producer: {0}", loadedDocument.DocumentInformation.Producer);
// Close the loaded document
loadedDocument.Close(true);
Console.ReadLine();

VB.NET

' Load the PDF document
Dim loadedDocument As New PdfLoadedDocument("DocumentInformation.pdf")
' Read the PDF document information
Dim author As String = loadedDocument.DocumentInformation.Author
Dim creationDate As DateTime = loadedDocument.DocumentInformation.CreationDate
Dim creator As String = loadedDocument.DocumentInformation.Creator
Dim keywords As String = loadedDocument.DocumentInformation.Keywords
Dim subject As String = loadedDocument.DocumentInformation.Subject
Dim title As String = loadedDocument.DocumentInformation.Title
' Close the document
loadedDocument.Close(True)

A complete working sample can be downloaded from PDFPropertiesSample.zip.

By executing the program, you will see the console window as follows. Output console window screenshot

Take a moment to peruse the documentation, where you can find options such as setting PDF document information, read and modify the document properties of an existing PDF document and features like adding XMP metadata, adding custom schemas and custom metadata to the PDF document, and removing custom metadata from a PDF with code examples.

Refer here to explore the rich set of Syncfusion Essential PDF features.

Note:

Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied