This practical, hands‑on tutorial teaches how to read PDF metadata in C#. It walks you through configuring your development environment, offers a clear step‑by‑step coding guide, and includes ready‑to‑run sample code that demonstrates the process. After extracting PDF metadata with C#, you can display it in the console or modify it as needed.
Steps to Read PDF Metadata in C#
- Establish the environment to add Conholdate.Total for .NET to fetch metadata
- Load the source PDF file into the Document class object to extract info
- Get a reference to the Info object in the loaded PDF file
- Display all the desired contents from the Info object
To view PDF metadata in C#, follow these straightforward steps: begin by loading the source PDF file, and then obtain the Info class object from it. This object holds all the metadata associated with the PDF, such as the creator, the timezone of modification time, the producer of the PDF file, creation date, and modification date, among others. Additionally, there are several methods available for modifying this metadata.
Code for Extracting Metadata from PDF in C#
This code sample shows how to read PDF metadata in C#, giving you straightforward access to core properties like Subject, Title, and Author. The Info class provides a full‑featured API for managing metadata—you can add custom entries, clear every field or just the custom ones, delete specific items, and check whether a field is user‑defined or built‑in.
Now that you’ve mastered extracting PDF metadata with C#, you’re ready to tackle the next challenge—reading PDF bookmarks. Dive into our comprehensive guide on how to read bookmarks in PDF using C#.