使用文本框
Contents
[
Hide
]
在 Aspose.Words 中,TextBox 类用于指定文本在形状内的显示方式。它提供了一个名为 parent 的公共属性来获取文本框的父形状,以允许客户从链接的 TextBox 中查找链接的 Shape。
创建链接
TextBox 类提供了 is_valid_link_target 方法来检查 TextBox 是否可以链接到目标文本框。
以下代码示例显示如何检查 TextBox
是否可以链接到目标文本框:
This file contains 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 |
检查文本框顺序
有多种方法可以在形状中显示文本。 text_box 可以是序列的头部、中间或尾部。
以下代码示例显示如何检查 TextBox 是序列的头、尾还是中间:
This file contains 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.") | |
断开链接
使用 text_box 方法,您可以断开到下一个 TextBox 的链接。
以下代码示例显示如何断开 TextBox 的链接:
This file contains 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() |