move_to_structured_document_tag method

move_to_structured_document_tag(structured_document_tag_index, character_index)

Moves the cursor to a structured document tag in the current section.

def move_to_structured_document_tag(self, structured_document_tag_index: int, character_index: int):
    ...
ParameterTypeDescription
structured_document_tag_indexintThe index of the structured document tag to move to.
character_indexintThe index of the character inside the structured document tag. A negative value allows you to specify a position from the end of the structured document tag. Use -1 to move to the end of the structured document tag. If the structured document tag is at the block level, and you want to move the cursor to the end of its last paragraph, specify -2.

Remarks

The navigation is performed inside the current story of the current section. That is, if you moved the cursor to the primary header of the first section, then structuredDocumentTagIndex specified the index of the structured document tag inside that header of that section.

When structuredDocumentTagIndex is greater than or equal to 0, it specifies an index from the beginning of the section with 0 being the first structured document tag. WhenstructuredDocumentTagIndex is less than 0, it specified an index from the end of the section with -1 being the last structured document tag.

move_to_structured_document_tag(structured_document_tag, character_index)

Moves the cursor to the structured document tag.

def move_to_structured_document_tag(self, structured_document_tag: aspose.words.markup.StructuredDocumentTag, character_index: int):
    ...
ParameterTypeDescription
structured_document_tagStructuredDocumentTagThe structured document tag to move to.
character_indexintThe index of the character inside the structured document tag. A negative value allows you to specify a position from the end of the structured document tag. Use -1 to move to the end of the structured document tag. If the structured document tag is at the block level, and you want to move the cursor to the end of its last paragraph, specify -2.

Examples

Shows how to move cursor of DocumentBuilder inside a structured document tag.

doc = aw.Document(MY_DIR + "Structured document tags.docx")
builder = aw.DocumentBuilder(doc)

# There is a several ways to move the cursor:
# 1 -  Move to the first character of structured document tag by index.
builder.move_to_structured_document_tag(1, 1)

# 2 -  Move to the first character of structured document tag by object.
tag = doc.get_child(aw.NodeType.STRUCTURED_DOCUMENT_TAG, 2, True).as_structured_document_tag()
builder.move_to_structured_document_tag(tag, 1)
builder.write(" New text.")

self.assertEqual("R New text.ichText", tag.get_text().strip())

# 3 -  Move to the end of the second structured document tag.
builder.move_to_structured_document_tag(1, -1)
self.assertTrue(builder.is_at_end_of_structured_document_tag)

# Get currently selected structured document tag.
builder.current_structured_document_tag.color = drawing.Color.green

doc.save(ARTIFACTS_DIR + "Document.MoveToStructuredDocumentTag.docx")

See Also