Extract PDF Metadata via Java

How to Edit PDF Metadata Using Java Library

Aspose.PDF for Java Logo

How to Extract PDF Metadata Using Java Library

To Extract Metadata from PDF files, we’ll use Aspose.PDF for Java API, which is a feature-rich, powerful, and easy-to-use conversion API for the Java platform. You can download its latest version directly from Maven and install it within your Maven-based project by adding the following configurations to the pom.xml.


    <name>Aspose Java AP</name>


<version>version of aspose-pdf API</version>

Extract PDF Metadata via Java

You need Aspose.PDF for Java 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.

System Requirements

Just make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with Java Runtime Environment for JSP/JSF Application and Desktop Applications.
  • Development environment like Eclipse or IntelliJ IDEA.
  • Aspose.PDF for Java library referenced in your project.

Extract Metadata of PDF - Java.

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

    Document pdfDocument = new Document(_dataDir + "sample.pdf");
    // Get document information
    DocumentInfo docInfo = pdfDocument.getInfo();
    // Show document information
    System.out.println("Author: " + docInfo.getAuthor());
    System.out.println("Creation Date: " + docInfo.getCreationDate());
    System.out.println("Keywords: " + docInfo.getKeywords());
    System.out.println("Modify Date: " + docInfo.getModDate());
    System.out.println("Subject: " + docInfo.getSubject());
    System.out.println("Title: " + docInfo.getTitle());

About Aspose.PDF for Java 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.