SubTextPart Object
Description
A SubTextPart object represents a user-defined part of a document. A document consists of the main text, and additionally other pieces of text such as text frames and headers or footers, called textparts. A programmer can define further parts called subtextparts to perform operations on smaller pieces of text. Each of the main textparts has a SubTextPartCollection which can be used to add and remove subtextparts or to save the subtextpart's text.
Syntax
SubTextPartExamples
The following example demonstrates SubTextPart in a practical document-editing workflow. A SubTextPart object represents a user-defined part of a document. A document consists of the main text, and additionally other pieces of text such as text frames and headers or footers, called textparts. A programmer can define further parts called subtextparts to perform operations on smaller pieces of text. Each of the main textparts has a SubTextPartCollection which can be used to add and remove subtextparts or to save the subtextpart's text.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textParts.getMainText(function(mainText) {
const subTextParts = mainText.subTextParts;
subTextParts.getItem(function(subTextPart) {
if (!subTextPart) {
console.warn("No sub text part is available at the current input position.");
return;
}
subTextPart.getID(
function(result) {
console.log("get id result:", result);
},
onTxError
);
}, onTxError);
}, onTxError);Members
Methods
| Method | Description |
|---|---|
| getChildren | Returns an array of the children of this SubTextPart. |
| getData | Gets additional data of the subtextpart. |
| getHighlightColor | Gets the highlight color for the subtextpart. |
| getHighlightMode | Gets a value indicating when the subtextpart is highlighted. |
| getID | Gets an identifier for a subtextpart. |
| getLength | Gets the number of characters in a subtextpart. |
| getName | Relates a user-defined name to a subtextpart. |
| getNestedLevel | Gets the subtextpart's nested level. |
| getNumber | Gets the subtextpart's number. The first subtextpart has the number 1. The number is defined through the textflow. A textpart with a smaller start position has a smaller number. When an outer subtextpart has the same start position than one of its nested textparts the outer textpart has a smaller number. |
| getOuterMostSubTextPart | Gets a subtextpart's outermost subtextpart. |
| getOuterSubTextPart | Gets a subtextpart's outer subtextpart. |
| getStart | Gets the first character position (one-based) of a subtextpart. |
| getText | Gets the subtextpart's text. |
| getTextFields | Returns an array of static text field information objects. |
| save | Saves the subtextpart in a certain format and sends the result back asynchronously by calling a given callback function. |
| scrollTo | Sets the current input position to the beginning of a subtextpart and scrolls it into the visible part of the document. |
| setData | Sets additional data of the subtextpart. |
| setHighlightColor | Sets the highlight color for the subtextpart. |
| setHighlightMode | Sets a value indicating when the subtextpart is highlighted. |
| setID | Sets an identifier for the subtextpart. |
| setName | Sets the name of a subtextpart. |