العمل مع مربعات النص
في 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 هو رأس التسلسل أو وسطه أو ذيله.
يوضح مثال التعليمات البرمجية التالي كيفية التحقق مما إذا كان 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 | |
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() |