PDF Metadata

View and edit built-in and custom properties of PDF documents with free cross-platform Apps and APIs

How to Set PDF Metadata Using Aspose.PDF Library

To Set Metadata from PDF files, we’ll use Aspose.PDF API, which is a feature-rich, powerful, and easy-to-use document manipulation API. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console. Aspose.PDF allows you to set file-specific information for a PDF, information like author, creation date, subject, and title.

Steps to Set Metadata of PDF


You need Aspose.PDF library to try the code in your environment.

  1. Load the PDF with an instance of Document.
  2. Set the values of the properties.
  3. Save the updated document using the Document class Save method.

Set PDF File Information via C#

This sample code shows how to set metadata informations of the PDF

    // Open document
    Document pdfDocument = new Document(dataDir + "SetFileInfo.pdf");

    // Specify document information
    DocumentInfo docInfo = new DocumentInfo(pdfDocument);

    docInfo.Author = "Aspose";
    docInfo.CreationDate = DateTime.Now;
    docInfo.Keywords = "Aspose.Pdf, DOM, API";
    docInfo.ModDate = DateTime.Now;
    docInfo.Subject = "PDF Information";
    docInfo.Title = "Setting PDF Document Information";

    dataDir = dataDir + "SetFileInfo_out.pdf";
    // Save output document
    pdfDocument.Save(dataDir);