Extract metadata from Microsoft Office Word documents

To extract metadata from Microsoft Office Word documents getMetadata method is used. This method allows to extract the following metadata:

NameDescription
titleThe title of the document.
subjectThe subject of the document.
keywordsThe keyword of the document.
commentsThe comments of the document.
content-statusThe content status of the document.
categoryThe category of the document.
companyThe company of the document.
managerThe manager of the document.
authorThe name of the document’s author.
last-authorThe name of the last document’s author.
hyperlink-baseThe base string used for evaluating relative hyperlinks in this document.
applicationThe name of the application.
application-versionThe version number of the application that created the document.
templateThe informational name of the document template.
created-timeThe time of the document creation.
last-saved-timeThe time of the the document when it was last saved.
last-printed-timeThe time of the document when it was last printed.
revision-numberThe document revision number.
total-editing-timeThe total editing time in minutes.

Here are the steps to extract metadata from Microsoft Office Word document:

  • Instantiate Parser object for the initial document;
  • Call getMetadata method and obtain collection of document metadata objects;
  • Iterate through the collection and get metadata names and values.

The following example demonstrates how to extract metadata from Microsoft Office Word document:

// Create an instance of Parser class
try (Parser parser = new Parser(Constants.SampleDocx)) {
    // Extract metadata from the document
    Iterable<MetadataItem> metadata = parser.getMetadata();
    // Iterate over metadata items
    for (MetadataItem item : metadata) {
        // Print an item name and value
        System.out.println(String.format("%s: %s", item.getName(), item.getValue()));
    }
}

More resources

GitHub examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free online document parser App

Along with full featured .NET library we provide simple, but powerful free Apps.

You are welcome to parse documents and extract data from PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Parser App.