Read and Modify Presentation Document Properties
- 2 minutes to read
Document properties are metadata fields stored in a presentation file. The DevExpress Presentation API allows you to read and modify both built-in and custom document properties.
Use the Presentation.getDocumentProperties() method to get a DocumentProperties object that contains all metadata fields.
Built-In Document Properties
Built-in document properties are standard metadata (such as author, category, title, and company). Some properties are automatically updated by the system, while others are user-defined.
| Method | Automatically Updated | Read Only |
|---|---|---|
| getApplication() | No | No |
| getAuthor() | No | No |
| getCategory() | No | No |
| getCompany() | No | No |
| getContentStatus() | No | No |
| getCreated() | Yes | No |
| getDescription() | No | No |
| getDocumentRevision() | No | No |
| getDocumentVersion() | No | No |
| getHiddenSlides() | No | Yes |
| getKeywords() | No | No |
| getLastModifiedBy() | Yes | No |
| getModified() | Yes | No |
| getNotes() | No | Yes |
| getPresentationFormat() | No | Yes |
| getPrinted() | Yes | No |
| getSecurity() | No | Yes |
| getSlides() | No | Yes |
| getSubject() | No | No |
| getTitle() | No | No |
| getVersion() | No | No |
Modify Built-In Document Properties
Use the DocumentProperties object to assign values to writable built-in properties:
try(Presentation presentation = new Presentation()) {
DocumentProperties documentProperties = presentation.getDocumentProperties();
documentProperties.setAuthor("Jane Doe");
documentProperties.setTitle("Innovating for the Future: Trends in Sustainable Technology");
documentProperties.setCompany("GreenTech Solutions Inc.");
documentProperties.setKeywords("Sustainability, Green Technology, Innovation");
// Perform additional presentation processing logic.
}
Create Custom Document Properties
Custom document properties are user-defined metadata. Custom properties are managed through the IDocumentCustomPropertyDictionary.
Use the DocumentProperties.getCustomProperties() method to access the dictionary of custom properties. Use the dictionary’s put() methods to store typed values as custom properties.
Custom document properties support the following data types:
StringBooleanDateTimeBigDecimalDoubleInt
The following code snippet adds custom properties to the presentation metadata:
IDocumentCustomPropertyDictionary customProperties =
presentation.getDocumentProperties().getCustomProperties();
// Add custom properties to the dictionary.
customProperties.put("string property", new DocumentCustomProperty("string"));
customProperties.put("boolean property", new DocumentCustomProperty(true));
customProperties.put("date property", new DocumentCustomProperty(Instant.now()));
customProperties.put("int property", new DocumentCustomProperty(5));
customProperties.put("double property", new DocumentCustomProperty(2.55));
// Get a custom property by key.
var propertyValue = customProperties.get("string property").getValue();