TX Text Control .NET Server

SubTextPart Object

Object|Introduced in 25.0

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

SubTextPart

Examples

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

MethodDescription
getChildrenReturns an array of the children of this SubTextPart.
getDataGets additional data of the subtextpart.
getHighlightColorGets the highlight color for the subtextpart.
getHighlightModeGets a value indicating when the subtextpart is highlighted.
getIDGets an identifier for a subtextpart.
getLengthGets the number of characters in a subtextpart.
getNameRelates a user-defined name to a subtextpart.
getNestedLevelGets the subtextpart's nested level.
getNumberGets 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.
getOuterMostSubTextPartGets a subtextpart's outermost subtextpart.
getOuterSubTextPartGets a subtextpart's outer subtextpart.
getStartGets the first character position (one-based) of a subtextpart.
getTextGets the subtextpart's text.
getTextFieldsReturns an array of static text field information objects.
saveSaves the subtextpart in a certain format and sends the result back asynchronously by calling a given callback function.
scrollToSets the current input position to the beginning of a subtextpart and scrolls it into the visible part of the document.
setDataSets additional data of the subtextpart.
setHighlightColorSets the highlight color for the subtextpart.
setHighlightModeSets a value indicating when the subtextpart is highlighted.
setIDSets an identifier for the subtextpart.
setNameSets the name of a subtextpart.