Working with metadata in Word Processing documents
Working with metadata in Word Processing documents
Leave feedback
GroupDocs.Metadata for Java provides functionality that allows working with different kinds of WordProcessing documents such as DOC, DOCX, ODT, etc. For the full list of supported document formats please refer to Supported document formats.
Detecting the exact type of a document
The following sample of code will help you to detect the exact type of a loaded document and extract some additional file format information.
As you can see the code sample uses the GroupDocs.Metadata search engine to retrieve all properties that are not marked with the BuiltIn tag. Since we call the findProperties method for a certain metadata package (instance of the WordProcessingPackage class), the search result will contain only metadata properties that are specific for WordProcessing documents.
Inspecting WordProcessing documents
The inspection feature that is introduced in this section doesn’t work with metadata directly but extracts some useful pieces of information that can be considered as metadata under some circumstances. For example, you may want to obtain information about digital signatures associated with a document, extract user comments from the document content, obtain pieces of hidden text, work with document revisions, etc. Please follow the example below to learn how to do that.
Most office applications are able to display simple text statistics for loaded documents. It can be an estimated word count, page count, character count, etc. The GroupDocs.Metadata API provides similar functionality for some document formats. The following code sample demonstrates how to obtain the text statistics for a WordProcessing document.
Dublin Core metadata is a set of certain metadata properties that are intended to describe various digital resources. Please find more information on the Dublin Core standard at https://en.wikipedia.org/wiki/Dublin_Core. The code sample below shows how to extract Dublin Core metadata from a WordProcessing document using the GroupDocs.Metadata API.
Please see the DublinCorePackage class to get more information on supported Dublin Core metadata properties.
Updating built-In metadata properties
Updating any built-in document properties is as simple as getting them. The following code sample demonstrates how to update built-in metadata properties in a WordProcessing document.
The GroupDocs.Metadata API also allows adding and updating custom metadata properties in a WordProcessing document. Please check the code sample below.
When you inspect a document GroupDocs.Metadata for Java forms a metadata package containing the extracted information. The package class also provides some basic methods that allow updating (or removing) the extracted properties. The following code sample demonstrates how to remove/update the inspection properties in a WordProcessing document.
The document statistics described in this section are not only calculated for WordProcessing documents, they can also be saved in the native metadata package with regular metadata properties. The following code sample demonstrates how to achieve this.