DocumentPropertyCollection indexer (1 of 2)

Returns a DocumentProperty object by the name of the property.

public virtual DocumentProperty this[string name] { get; }
Parameter Description
name The case-insensitive name of the property to retrieve.


Returns null if a property with the specified name is not found.


Shows how to create a custom document property which contains a date and time.

Document doc = new Document();

doc.CustomDocumentProperties.Add("AuthorizationDate", DateTime.Now);

Console.WriteLine($"Document authorized on {doc.CustomDocumentProperties["AuthorizationDate"].ToDateTime()}");

See Also

DocumentPropertyCollection indexer (2 of 2)

Returns a DocumentProperty object by index.

public DocumentProperty this[int index] { get; }
Parameter Description
index Zero-based index of the DocumentProperty to retrieve.


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