PDF Document Metadata Solution

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

Download
Aspose.PDF for .NET Logo

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.

System Requirements


Just make sure that you have the following prerequisites.

  • Microsoft Windows with .NET or any other OS with Java SDK or OS with GNU C/C++ Compiler collection
  • Development environments like Microsoft Visual Studio, Eclipse, Atom
  • Aspose.PDF for .NET, Java, C++, Python for .NET library referenced in your project.

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);

About Aspose.PDF API

Aspose.PDF API can be used for PDF document manipulation and parsing within applications. One can create, modify, compress, secure, print or save PDF to TXT, HTML, PCL, XFA, XML, XPS, EPUB, TEX, Images and more formats. Aspose.PDF is a standalone API and it does not depend on any software including Adobe Acrobat.