CustomDocumentProperties class

A collection of custom document properties.

public class CustomDocumentProperties : DocumentPropertyCollection


Name Description
Count { get; } Gets number of items in the collection.
Item { get; } Returns a DocumentProperty object by index.
virtual Item { get; } Returns a DocumentProperty object by the name of the property.


Name Description
Add(string, bool) Creates a new custom document property of the PropertyType.Boolean data type.
Add(string, DateTime) Creates a new custom document property of the PropertyType.DateTime data type.
Add(string, double) Creates a new custom document property of the PropertyType.Float data type.
Add(string, int) Creates a new custom document property of the PropertyType.Number data type.
Add(string, string) Creates a new custom document property of the PropertyType.String data type.
AddLinkToContent(string, string) Creates a new linked to content custom document property.
Clear() Removes all properties from the collection.
Contains(string) Returns true if a property with the specified name exists in the collection.
GetEnumerator() Returns an enumerator object that can be used to iterate over all items in the collection.
IndexOf(string) Gets the index of a property by name.
Remove(string) Removes a property with the specified name from the collection.
RemoveAt(int) Removes a property at the specified index.


Each DocumentProperty object represents a custom property of a container document.

The names of the properties are case-insensitive.

The properties in the collection are sorted alphabetically by name.


Shows how to work with custom document properties.

Document doc = new Document(MyDir + "Properties.docx");

// Every document contains a collection of custom properties, which, like the built-in properties, are key-value pairs.
// The document has a fixed list of built-in properties. The user creates all of the custom properties. 
Assert.AreEqual("Value of custom document property", doc.CustomDocumentProperties["CustomProperty"].ToString());

doc.CustomDocumentProperties.Add("CustomProperty2", "Value of custom document property #2");

Console.WriteLine("Custom Properties:");
foreach (var customDocumentProperty in doc.CustomDocumentProperties)

See Also