CustomDocumentProperties class
CustomDocumentProperties class
A collection of custom document properties. To learn more, visit the Work with Document Properties documentation article.
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.
Inheritance: CustomDocumentProperties → DocumentPropertyCollection
Properties
Name | Description |
---|---|
count | Gets number of items in the collection. (Inherited from DocumentPropertyCollection) |
this[] | (Inherited from DocumentPropertyCollection) |
this[] | (Inherited from DocumentPropertyCollection) |
Methods
Name | Description |
---|---|
add(name, value) | Creates a new custom document property of the PropertyType.String data type. |
add(name, value) | Creates a new custom document property of the PropertyType.Number data type. |
add(name, value) | Creates a new custom document property of the PropertyType.DateTime data type. |
add(name, value) | Creates a new custom document property of the PropertyType.Boolean data type. |
add(name, value) | Creates a new custom document property of the PropertyType.Double data type. |
addLinkToContent(name, linkSource) | Creates a new linked to content custom document property. |
clear() | Removes all properties from the collection. (Inherited from DocumentPropertyCollection) |
contains(name) | Returns true if a property with the specified name exists in the collection.(Inherited from DocumentPropertyCollection) |
indexOf(name) | Gets the index of a property by name. (Inherited from DocumentPropertyCollection) |
remove(name) | Removes a property with the specified name from the collection. (Inherited from DocumentPropertyCollection) |
removeAt(index) | Removes a property at the specified index. (Inherited from DocumentPropertyCollection) |
Examples
Shows how to work with custom document properties.
let doc = new aw.Document(base.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.
expect(doc.customDocumentProperties.at("CustomProperty").toString()).toEqual("Value of custom document property");
doc.customDocumentProperties.add("CustomProperty2", "Value of custom document property #2");
/*console.log("Custom Properties:");
for (let customDocumentProperty of doc.customDocumentProperties)
{
console.log(customDocumentProperty.name);
console.log(`\tType:\t${customDocumentProperty.type}`);
console.log(`\tValue:\t\"${customDocumentProperty.toString()}\"`);
}*/
See Also
- module Aspose.Words.Properties
- class DocumentPropertyCollection
- class Document
- property Document.builtInDocumentProperties
- property Document.customDocumentProperties