PDFOne .NET
Powerful all-in-one PDF library for .NET
Compatibility
VS 2008 VS 2005 CLR 2.0

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 Developer Tools
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.

XtremePDFConverter VCL

A Delphi/C++Builder component to intelligently convert PDF to user-friendly Word RTF documents.

PDFOne .NET

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

XtremeDocumentStudio .NET

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

PDFOne (for Java™)

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

XtremeFontEngine (for Java)

Java font engine to render glyphs from Type 1, Type 2 (CFF), and TrueType fonts

Our Office Productivity Applications
Free PDF Reader

A free, fast, and portable application for viewing, printing and converting PDF documents.

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

This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows XP users are advised to use Microsoft ClearType Tuning for optimal experience. Also, please use the latest version of a standards-compliant browser such as Firefox, Opera, or Dragon (Chromium).