CustomDocumentProperties Class

A collection of custom document properties.

Inheritance Hierarchy

Namespace:  Aspose.Words.Properties
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.9.0

Syntax

public class CustomDocumentProperties : DocumentPropertyCollection

The CustomDocumentProperties type exposes the following members.

Properties

Methods

  NameDescription
Public methodCode exampleAdd(String, Boolean)
Creates a new custom document property of the PropertyType.Boolean data type.
Public methodCode exampleAdd(String, DateTime)
Creates a new custom document property of the PropertyType.DateTime data type.
Public methodCode exampleAdd(String, Double)
Creates a new custom document property of the PropertyType.Float data type.
Public methodCode exampleAdd(String, Int32)
Creates a new custom document property of the PropertyType.Number data type.
Public methodCode exampleAdd(String, String)
Creates a new custom document property of the PropertyType.String data type.
Public methodCode exampleAddLinkToContent
Creates a new linked to content custom document property.
Public methodCode exampleClear
Removes all properties from the collection.
(Inherited from DocumentPropertyCollection.)
Public methodCode exampleContains
Returns true if a property with the specified name exists in the collection.
(Inherited from DocumentPropertyCollection.)
Public methodEquals (Inherited from Object.)
Public methodCode exampleGetEnumerator
Returns an enumerator object that can be used to iterate over all items in the collection.
(Inherited from DocumentPropertyCollection.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodCode exampleIndexOf
Gets the index of a property by name.
(Inherited from DocumentPropertyCollection.)
Public methodCode exampleRemove
Removes a property with the specified name from the collection.
(Inherited from DocumentPropertyCollection.)
Public methodCode exampleRemoveAt
Removes a property at the specified index.
(Inherited from DocumentPropertyCollection.)
Public methodToString (Inherited from Object.)

Remarks

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

Remarks

The names of the properties are case-insensitive.

The properties in the collection are sorted alphabetically by name.

Examples

Shows how to work with custom document properties.
Document doc = new Document(MyDir + "Properties.docx");

// A document's built-in properties contain a set of predetermined keys
// with values such as the author's name or document's word count
// We can add our own keys and values to a custom properties collection also
// Before we add a custom property, we need to make sure that one with the same name does not already exist
Assert.AreEqual("Value of custom document property", doc.CustomDocumentProperties["CustomProperty"].ToString());

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

// Iterate over all the custom document properties
Console.WriteLine("Custom Properties:");
foreach (var customDocumentProperty in doc.CustomDocumentProperties)
{
    Console.WriteLine(customDocumentProperty.Name);
    Console.WriteLine($"\tType:\t{customDocumentProperty.Type}");
    Console.WriteLine($"\tValue:\t\"{customDocumentProperty.Value}\"");
}

See Also