DocumentProperty
Contents
[
Hide
]DocumentProperty class
Represents a custom or built-in document property.
To learn more, visit the Work with Document Properties documentation article.
public class DocumentProperty
Properties
| Name | Description |
|---|---|
| IsLinkToContent { get; } | Shows whether this property is linked to content or not. |
| LinkSource { get; } | Gets the source of a linked custom document property. |
| Name { get; } | Returns the name of the property. |
| Type { get; } | Gets the data type of the property. |
| Value { get; set; } | Gets or sets the value of the property. |
Methods
| Name | Description |
|---|---|
| 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. |
| override ToString() | Returns the property value as a string formatted according to the current locale. |
Examples
Shows how to work with built-in document properties.
Document doc = new Document(MyDir + "Properties.docx");
// The "Document" object contains some of its metadata in its members.
Console.WriteLine($"Document filename:\n\t \"{doc.OriginalFileName}\"");
// The document also stores metadata in its built-in properties.
// Each built-in property is a member of the document's "BuiltInDocumentProperties" object.
Console.WriteLine("Built-in Properties:");
foreach (DocumentProperty docProperty in doc.BuiltInDocumentProperties)
{
Console.WriteLine(docProperty.Name);
Console.WriteLine($"\tType:\t{docProperty.Type}");
// Some properties may store multiple values.
if (docProperty.Value is ICollection<object>)
{
foreach (object value in docProperty.Value as ICollection<object>)
Console.WriteLine($"\tValue:\t\"{value}\"");
}
else
{
Console.WriteLine($"\tValue:\t\"{docProperty.Value}\"");
}
}
See Also
- class DocumentPropertyCollection
- namespace Aspose.Words.Properties
- assembly Aspose.Words