Extract PDF Metadata via C++

Extract metadata from PDF document. Use Aspose.PDF for C++ to modify PDF files programmatically

How to Extract PDF Metadata Using C++

Extract metadata from PDF using Aspose.PDF for C++. Accessing a document’s metadata means getting information about that file, such as its title, author, when it was created, and specific keywords. Extract metadata, helps organize a large collection of PDF more effectively. The data extracted from metadata improves how you can search for files. Users can quickly locate specific documents by using keywords or details found in the extracted metadata. Extracting metadata gives valuable insights into what a file contains. It might offer a brief summary of key details about the file, making it easier to understand what the document is about without having to open it. Extract metadata helps ensure a document is authentic. You can check details like the author’s name when it was created, or its modification history. This verification is crucial for confirming a PDF reliability. By offering concise details about the content of a PDF, the extracted metadata makes the user experience much better. It helps users easily identify and work with documents. Overall, extracting PDF metadata gives many advantages, such as more efficient document management, improved search options, compliance with standards, and an overall enhanced user experience. Extract metadata from PDF via Aspose, and solve all the necessary tasks in the work with data. In order to Extract Metadata from PDF files, we’ll use Aspose.PDF for C++ API, which is a feature-rich, powerful, and easy-to-use document manipulation API for the C++ platform. Open NuGet package manager, search for Aspose.PDF.Cpp and install. You may also use the following command from the Package Manager Console.

Package Manager Console

PM > Install-Package Aspose.PDF.Cpp

Extract PDF Metadata via C++


You need Aspose.PDF for C++ to try the code in your environment.

  1. Load the PDF with an instance of Document.
  2. Get DocumentInfo using Document.Info property.
  3. Access & display different Document.Info properties.

The provided C++ code snippet shows how to extract metadata from PDF by Aspose.PDF library. It opens a PDF file named ‘GetFileInfo.pdf’ located in the directory specified by the variable ‘DIR_INPUT_METADATA’. The code retrieves various details from the document using the ‘info’ function. It displays specific metadata information from the PDF, such as the author’s name, creation date, keywords, modification date, subject, and title. The code uses the ‘print’ function to show this information. This code snippet is a simplified example of how you might use a Aspose.PDF library or framework to extract metadata from PDF file.

Extract Metadata of PDF - C++

This sample code shows how to extract metadata informations of the PDF file

Input file:

File not added

Output format:

Output file:

    auto pdfDocument = MakeObject<Document>(_dataDir + u"SetFileInfo.pdf");
    auto docInfo = MakeObject<DocumentInfo>(pdfDocument);
    docInfo->set_Author(u"Aspose");
    docInfo->set_CreationDate(DateTime::get_Now());
    docInfo->set_Keywords (u"Aspose.Pdf, DOM, API");
    docInfo->set_ModDate (DateTime::get_Now());
    docInfo->set_Subject (u"PDF Information");
    docInfo->set_Title (u"Setting PDF Document Information");
    // Save output document
    pdfDocument->Save(_dataDir + u"SetFileInfo_out.pdf");