PDFOne .NET
Powerful all-in-one PDF library for .NET
Compatibility
VS 2005/2008/2010/2012/2013

Reading and Writing PDF Document Information Properties In .NET

Learn how to read and edit document information properties of a PDF file using PDFOne .NET.
By Raju Sinha

Document properties of a PDF file include metadata such as document information, document restrictions, and font information.

This metadata, which contains precise information about the whole document, can be extracted by applications (such as file indexing services, search engine spiders, and PDF viewers and printers). Document properties can also be easily read by humans.

In previous articles, you learned about using PDFOne .NET to read and change some of these documentation properties. In this article, you will learn about how to change document information properties such as title, author, subject, and keywords.

To read the document information properties of a PDF document, you need to first load the document using an object of the PDFDocument class and then access the PDFDocument.DocInfo property.

// Create a new document object
PDFDocument doc = new PDFDocument();
 
// Load an existing PDF document
doc.Load("existing_doc.pdf");

// Display document information properties
Console.WriteLine(doc.DocInfo.Title);
Console.WriteLine(doc.DocInfo.Author);
Console.WriteLine(doc.DocInfo.Subject);
Console.WriteLine(doc.DocInfo.Keywords);
Console.WriteLine(doc.DocInfo.Creator);

Console.ReadLine(); // Press Return key to continue

The PDFDocument.DocInfo property is an object of the PDFDocInfo class. It allows you to set or get document information properties of the loaded PDF document. In the code snippet below, we modify the document information properties.

...
 
// Modify document information properties
doc.DocInfo.Title = "To Be Or Not To Be";
doc.DocInfo.Subject = "Hamlet's Immortal Dilemma";
doc.DocInfo.Author = "Raju Sinha";
doc.DocInfo.Keywords = 
  "hamlet, shakespeare, dilemma, english, drama, play";
doc.DocInfo.Creator = 
  "Gnostice PDFOne .NET component library";

// Save changes
doc.OpenAfterCreate = true;
doc.Save("modified_doc.pdf");
doc.Close();
Modified document information properties of the PDF document

---o0O0o---

Our .NET Developer Tools
Gnostice Document Studio .NET

Multi-format document-processing component suite for .NET developers.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Delphi/C++Builder developer tools
Gnostice Document Studio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
Gnostice Document Studio Java

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Our Platform-Agnostic Cloud and On-Premises APIs
StarDocs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2023 Gnostice Information Technologies Private Limited. All rights reserved.