Working with TextBoxes
Contents
[
Hide
]
In Aspose.Words, TextBox class is used to specify how a text is displayed inside a shape. It provides a public property named as parent to get the parent shape for the text box to allow customer to find linked Shape from linked TextBox.
Creating a Link
TextBox class provides is_valid_link_target method in order to check whether the TextBox can be linked to the target Textbox as shown in the code snippet given below:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET | |
doc = aw.Document() | |
shape1 = aw.drawing.Shape(doc, aw.drawing.ShapeType.TEXT_BOX) | |
shape2 = aw.drawing.Shape(doc, aw.drawing.ShapeType.TEXT_BOX) | |
textBox1 = shape1.text_box | |
textBox2 = shape2.text_box | |
if textBox1.is_valid_link_target(textBox2) : | |
textBox1.next = textBox2 |
Check TextBox Sequence
The following code snippets shows how to check if Shape.text_box is a Head, a Tail or a Middle of the sequence:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET | |
doc = aw.Document() | |
shape = aw.drawing.Shape(doc, aw.drawing.ShapeType.TEXT_BOX) | |
textBox = shape.text_box | |
if (textBox.next != None and textBox.previous == None) : | |
print("The head of the sequence") | |
if (textBox.next != None and textBox.previous != None) : | |
print("The Middle of the sequence.") | |
if (textBox.next == None and textBox.previous != None) : | |
print("The Tail of the sequence.") | |
Breaking a Link
The following code snippet shows how to break a link for a Shape.text_box:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET | |
doc = aw.Document() | |
shape = aw.drawing.Shape(doc, aw.drawing.ShapeType.TEXT_BOX) | |
textBox = shape.text_box | |
# Break a forward link. | |
textBox.break_forward_link() | |
# Break a forward link by setting a None. | |
textBox.next = None | |
# Break a link, which leads to this textbox. | |
if textBox.previous != None : | |
textBox.previous.break_forward_link() |