Back to Devexpress

DocumentCustomPropertyDictionary Class

officefileapi-devexpress-dot-docs-dot-presentation-b124681d.md

latest6.1 KB
Original Source

DocumentCustomPropertyDictionary Class

Contains custom document properties of a presentation.

Namespace : DevExpress.Docs.Presentation

Assembly : DevExpress.Docs.Presentation.v25.2.dll

NuGet Package : DevExpress.Docs.Presentation

Declaration

csharp
public class DocumentCustomPropertyDictionary :
    PresentationDictionary<string, DocumentCustomProperty>
vb
Public Class DocumentCustomPropertyDictionary
    Inherits PresentationDictionary(Of String, DocumentCustomProperty)

The following members return DocumentCustomPropertyDictionary objects:

Remarks

The DocumentCustomPropertyDictionary class allows you to add custom metadata (or document properties) to the presentation file. Call the Add method to add a new custom property. The following property types are available:

The following code snippet creates new custom properties:

csharp
using DevExpress.Docs.Presentation;

using (var presentation = new Presentation(File.ReadAllBytes("C:\\Documents\\Presentation.pptx")))
{
    var customProperties = presentation.DocumentProperties.CustomProperties;
    customProperties.Add("string property", "string");
    customProperties.Add("boolean property", true);
    customProperties.Add("date property", DateTime.Now);
    customProperties.Add("int property", 5);
    customProperties.Add("double property", 2.55);

    presentation.SaveDocument(new FileStream("C:\\Documents\\Presentation_upd.pptx", FileMode.Create));
}
vb
Imports DevExpress.Docs.Presentation

Using presentation = New Presentation(File.ReadAllBytes("C:\Documents\Presentation.pptx"))
  Dim customProperties = presentation.DocumentProperties.CustomProperties
  customProperties.Add("string property", "string")
  customProperties.Add("boolean property", True)
  customProperties.Add("date property", Date.Now)
  customProperties.Add("int property", 5)
  customProperties.Add("double property", 2.55)

  presentation.SaveDocument(New FileStream("C:\Documents\Presentation_upd.pptx", FileMode.Create))
End Using

You can also use the Item[TKey] property to add a new custom property. Set a value to the property with the name specified in square brackets. If a property with this name does not exist, it is created automatically. Otherwise, an exception occurs.

csharp
using DevExpress.Docs.Presentation;

using (var presentation = new Presentation(File.ReadAllBytes("C:\\Documents\\Presentation.pptx"))) {
  var customProperties = presentation.DocumentProperties.CustomProperties;
  customProperties["string property"] ="string";
  customProperties["boolean property"] = true;
  customProperties["date property"] = DateTime.Now;
  customProperties["int property"] = 5;
  customProperties["double property"] = 2.55; 
  presentation.SaveDocument(new FileStream("C:\\Documents\\Presentation_upd.pptx", FileMode.Create));
}
vb
Imports DevExpress.Docs.Presentation

Using presentation = New Presentation(File.ReadAllBytes("C:\Documents\Presentation.pptx"))
  Dim customProperties = presentation.DocumentProperties.CustomProperties
  customProperties("string property") ="string"
  customProperties("boolean property") = True
  customProperties("date property") = Date.Now
  customProperties("int property") = 5
  customProperties("double property") = 2.55
  presentation.SaveDocument(New FileStream("C:\Documents\Presentation_upd.pptx", FileMode.Create))
End Using

Implements

IDictionary<String, DocumentCustomProperty>

ICollection<KeyValuePair<String, DocumentCustomProperty>>

IEnumerable<KeyValuePair<String, DocumentCustomProperty>>

IEnumerable

Inheritance

Object PresentationDictionary<String, DocumentCustomProperty> DocumentCustomPropertyDictionary

See Also

DocumentCustomPropertyDictionary Members

DevExpress.Docs.Presentation Namespace