Aspose::Words::Properties::DocumentProperty class

DocumentProperty class

Represents a custom or built-in document property. To learn more, visit the Work with Document Properties documentation article.

class DocumentProperty : public System::Object

Methods

MethodDescription
get_IsLinkToContent()Shows whether this property is linked to content or not.
get_LinkSource() constGets the source of a linked custom document property.
get_Name() constReturns the name of the property.
get_Type() constGets the data type of the property.
get_Value()Gets or sets the value of the property.
GetType() const override
Is(const System::TypeInfo&) const override
set_Value(const System::SharedPtr<System::Object>&)Setter for Aspose::Words::Properties::DocumentProperty::get_Value.
ToBool()Returns the property value as bool.
ToByteArray()Returns the property value as byte array.
ToDateTime()Returns the property value as DateTime in UTC.
ToDouble()Returns the property value as double.
ToInt()Returns the property value as integer.
ToString() const overrideReturns the property value as a string formatted according to the current locale.
static Type()

Examples

Shows how to work with built-in document properties.

auto doc = MakeObject<Document>(MyDir + u"Properties.docx");

// The "Document" object contains some of its metadata in its members.
std::cout << "Document filename:\n\t \"" << doc->get_OriginalFileName() << "\"" << std::endl;

// The document also stores metadata in its built-in properties.
// Each built-in property is a member of the document's "BuiltInDocumentProperties" object.
std::cout << "Built-in Properties:" << std::endl;
for (const auto& docProperty : System::IterateOver(doc->get_BuiltInDocumentProperties()))
{
    std::cout << docProperty->get_Name() << std::endl;
    std::cout << String::Format(u"\tType:\t{0}", docProperty->get_Type()) << std::endl;

    // Some properties may store multiple values.
    if (System::ObjectExt::Is<System::Collections::Generic::ICollection<SharedPtr<System::Object>>>(docProperty->get_Value()))
    {
        for (const auto& value : System::IterateOver(
                 System::AsCast<System::Collections::Generic::ICollection<SharedPtr<System::Object>>>(docProperty->get_Value())))
        {
            std::cout << "\tValue:\t\"" << value << "\"" << std::endl;
        }
    }
    else
    {
        std::cout << "\tValue:\t\"" << docProperty->get_Value() << "\"" << std::endl;
    }
}

See Also