How to Read PDF Metadata in C#

This how-to guide contains information on how to read PDF metadata in C#. It provides all the necessary resources to establish the environment, a step-wise process to write the program, and a runnable sample code for the demonstration of the feature. Once you get PDF metadata in C#, you may either display it on the console or modify it if required.

Steps to Read PDF Metadata in C#

  1. Establish the environment to add Aspose.PDF for .NET to fetch metadata
  2. Load the source PDF file into the Document class object to extract info
  3. Get a reference to the Info object in the loaded PDF file
  4. Display all the desired contents from the Info object

These simple steps can be used to view PDF metadata in C# by loading the source PDF file and then accessing the Info class object from it. It contains all the metadata of the PDF like creator, the timezone of the modification time, the producer of this PDF file, creation date, and modification date to name a few. There are a few methods also that can be used to manipulate this metadata.

Code for Extracting Metadata from PDF in C#

This code demonstrates the process to display the PDF metadata in C#. You can fetch other properties also like subject, title, and author. There are different methods in the Info class object that can be used to add custom metadata, clear all the fields in the metadata, clear custom fields only, remove a specified field, and check if a particular field is custom or predefined.

This article has guided us to fetch metadata from a PDF file. If you want to learn other features like getting images from a PDF file, refer to the article on how to get images from a PDF in C#.

 English