Aspose::Words::Properties::CustomDocumentProperties class

CustomDocumentProperties class

A collection of custom document properties. To learn more, visit the Work with Document Properties documentation article.

class CustomDocumentProperties : public DocumentPropertyCollection

Methods

MethodDescription
Add(const System::String &, System::DateTime)Creates a new custom document property of the DateTime data type.
Add(const System::String &, bool)Creates a new custom document property of the Boolean data type.
Add(const System::String &, const System::String &)Creates a new custom document property of the String data type.
Add(const System::String &, double)Creates a new custom document property of the Double data type.
Add(const System::String &, int32_t)Creates a new custom document property of the Number data type.
AddLinkToContent(const System::String &, const System::String &)Creates a new linked to content custom document property.
Clear()Removes all properties from the collection.
Contains(const System::String &)Returns true if a property with the specified name exists in the collection.
GetEnumerator() overrideReturns an enumerator object that can be used to iterate over all items in the collection.
IndexOf(const System::String &)Gets the index of a property by name.
Remove(const System::String &)Removes a property with the specified name from the collection.
RemoveAt(int32_t)Removes a property at the specified index.
get_Count()Gets number of items in the collection.
virtual idx_get(System::String)Returns a DocumentProperty object by the name of the property.
idx_get(int32_t)Returns a DocumentProperty object by index.

Remarks

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.

Examples

Shows how to work with custom document properties.

auto doc = System::MakeObject<Aspose::Words::Document>(System::String(get_MyDir() + u"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_EQ(System::ObjectExt::ToString(doc->get_CustomDocumentProperties()->idx_get(u"CustomProperty")), u"Value of custom document property");

doc->get_CustomDocumentProperties()->Add(u"CustomProperty2", System::String(u"Value of custom document property #2"));

std::cout << "Custom Properties:" << std::endl;
for (auto&& customDocumentProperty : System::IterateOver(doc->get_CustomDocumentProperties()))
{
    std::cout << customDocumentProperty->get_Name() << std::endl;
    std::cout << System::String::Format(u"\tType:\t{0}", customDocumentProperty->get_Type()) << std::endl;
    std::cout << System::String::Format(u"\tValue:\t\"{0}\"", customDocumentProperty->get_Value()) << std::endl;
}

See Also