Working with metadata in ProjectManagement formats
Leave feedback
GroupDocs.Metadata for Java provides functionality that allows working with MPP files created by different versions of Microsoft Project. Please see the code samples below for more information.
To access built-in metadata of a ProjectManagement document, please use the getDocumentProperties method defined in the DocumentRootPackage class.
The following code snippet extracts built-in metadata properties and displays them on the screen.
advanced_usage.managing_metadata_for_specific_formats.
try (Metadata metadata = new Metadata(Constants.InputMpp)) {
ProjectManagementRootPackage root = metadata.getRootPackageGeneric();
System.out.println(root.getDocumentProperties().getAuthor());
System.out.println(root.getDocumentProperties().getCreationDate());
System.out.println(root.getDocumentProperties().getCompany());
System.out.println(root.getDocumentProperties().getCategory());
System.out.println(root.getDocumentProperties().getKeywords());
System.out.println(root.getDocumentProperties().getRevision());
System.out.println(root.getDocumentProperties().getSubject());
// ...
}
If you need to extract custom metadata properties of a ProjectManagement document please follow the code sample below.
advanced_usage.managing_metadata_for_specific_formats.
try (Metadata metadata = new Metadata(Constants.InputMpp)) {
ProjectManagementRootPackage root = metadata.getRootPackageGeneric();
IReadOnlyList<MetadataProperty> customProperties = root.getDocumentProperties().findProperties(new ContainsTagSpecification(Tags.getDocument().getBuiltIn()).not());
for (MetadataProperty property : customProperties) {
System.out.println(String.format("%s = %s", property.getName(), property.getValue()));
}
}
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 ProjectManagement document.
advanced_usage.managing_metadata_for_specific_formats.
try (Metadata metadata = new Metadata(Constants.InputMpp)) {
ProjectManagementRootPackage root = metadata.getRootPackageGeneric();
root.getDocumentProperties().setAuthor("test author");
root.getDocumentProperties().setCreationDate(new Date());
root.getDocumentProperties().setCompany("GroupDocs");
root.getDocumentProperties().setComments("test comment");
root.getDocumentProperties().setKeywords("metadata, built-in, update");
// ...
metadata.save(Constants.OutputMpp);
}
The GroupDocs.Metadata API also allows adding and updating custom metadata properties in a ProjectManagement document. Please check the code sample below.
advanced_usage.managing_metadata_for_specific_formats.
try (Metadata metadata = new Metadata(Constants.InputMpp)) {
ProjectManagementRootPackage root = metadata.getRootPackageGeneric();
root.getDocumentProperties().set("customProperty1", "some value");
root.getDocumentProperties().set("customProperty2", 7);
root.getDocumentProperties().set("customProperty3", true);
metadata.save(Constants.OutputMpp);
}
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full featured Java library we provide simple, but powerful free Apps.
You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.