การทำงานกับกล่องข้อความ
ใน Aspose.Words คลาส TextBox ใช้เพื่อระบุวิธีการแสดงข้อความภายในรูปร่าง โดยจัดเตรียมทรัพย์สินสาธารณะชื่อ parent เพื่อรับรูปร่างหลักสำหรับกล่องข้อความเพื่อให้ลูกค้าค้นหา Shape ที่เชื่อมโยงจาก TextBox ที่เชื่อมโยง
การสร้างลิงค์
คลาส TextBox จัดเตรียมวิธี is_valid_link_target เพื่อตรวจสอบว่า TextBox สามารถเชื่อมโยงกับกล่องข้อความเป้าหมายได้หรือไม่
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีตรวจสอบว่า TextBox
สามารถเชื่อมโยงกับกล่องข้อความเป้าหมายได้หรือไม่:
# 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 อาจเป็น Head, Middle หรือ Tail ของลำดับก็ได้
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีตรวจสอบว่า TextBox เป็น Head, Tail หรือ Middle ของลำดับหรือไม่:
# 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:
# 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() |