Working with PDF File Metadata in C#

The following code snippet also work with Aspose.PDF.Drawing library.

Get PDF File Information

In order to get file specific information of a PDF file, you first need to get the DocumentInfo object using Info property of the Document object. Once the DocumentInfo object is retrieved, you can get the values of the individual properties. The following code snippet shows you how to get PDF file information.

Set PDF File Information

Aspose.PDF for .NET allows you to set file-specific information for a PDF, information like author, creation date, subject, and title. To set this information:

  1. Create a DocumentInfo object.
  2. Set the values of the properties.
  3. Save the updated document using the Document class’ Save method.

The following code snippet shows you how to set PDF file information.

Get XMP Metadata from PDF File

Aspose.PDF allows you to access a PDF file’s XMP metadata. To get a PDF file’s metadata:

  1. Create a Document object and open the input PDF file.
  2. Get the file’s metadata using the Metadata property.

The following code snippet shows you how to get metadata from the PDF file.

Set XMP Metadata in a PDF File

Aspose.PDF allows you to set metadata in a PDF file. To set metadata:

  1. Create a Document object.
  2. Set metadata values using the Metadata property.
  3. Save the updated document using the Save method of the Document object.

The following code snippet shows you how to set metadata in a PDF file.

Insert Metadata with Prefix

Some developers need to create a new metadata namespace with a prefix. The following code snippet shows how to insert metadata with prefix.