การทำงานกับลิงก์TextBoxes
ในAspose.WordsคลาสTextBoxจะใช้เพื่อระบุวิธีแสดงข้อความภายในรูปร่าง รับกล่องข้อความเพื่อให้ลูกค้าสามารถค้นหาที่เชื่อมโยงShapeจากการเชื่อมโยงTextBox.
สร้างลิงก์
คลาสTextBoxมีวิธีการIsValidLinkTargetเพื่อตรวจสอบว่าTextBoxสามารถเชื่อมโยงกับเป้าหมายTextbox.
ตัวอย่างรหัสต่อไปนี้แสดงวิธีการตรวจสอบว่าTextBox
สามารถเชื่อมโยงไปยังกล่องข้อความเป้าห:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
Document doc = new Document(); | |
Shape shape1 = new Shape(doc, ShapeType.TEXT_BOX); | |
Shape shape2 = new Shape(doc, ShapeType.TEXT_BOX); | |
TextBox textBox1 = shape1.getTextBox(); | |
TextBox textBox2 = shape2.getTextBox(); | |
if (textBox1.isValidLinkTarget(textBox2)) | |
textBox1.setNext(textBox2); |
ตรวจสอบTextBoxลำดับ
มีหลายวิธีในการแสดงข้อความในรูปร่าง TextBoxอาจเป็นหัวกลางหรือหางของลำดับ.
ตัวอย่างรหัสต่อไปนี้แสดงวิธีการตรวจสอบว่าTextBoxเป็นหัวหางหรือตรงกลางของลำดับ:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
Document doc = new Document(); | |
Shape shape = new Shape(doc, ShapeType.TEXT_BOX); | |
TextBox textBox = shape.getTextBox(); | |
if ((textBox.getNext() != null) && (textBox.getPrevious() == null)) { | |
System.out.println("The head of the sequence"); | |
} | |
if ((textBox.getNext() != null) && (textBox.getPrevious() != null)) { | |
System.out.println("The Middle of the sequence."); | |
} | |
if ((textBox.getNext() == null) && (textBox.getPrevious() != null)) { | |
System.out.println("The Tail of the sequence."); | |
} |
แบ่งการเชื่อมโยง
โดยใช้วิธีการBreakForwardLinkคุณสามารถแบ่งการเชื่อมโยงไปยังTextBoxต่อไป.
ตัวอย่างรหัสต่อไปนี้แสดงวิธีการแบ่งการเชื่อมโยงสำหรับTextBox:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
Document doc = new Document(); | |
Shape shape = new Shape(doc, ShapeType.TEXT_BOX); | |
TextBox textBox = shape.getTextBox(); | |
// Break a forward link | |
textBox.breakForwardLink(); | |
// Break a forward link by setting a null | |
textBox.setNext(null); | |
// Break a link, which leads to this textbox | |
if (textBox.getPrevious() != null) | |
textBox.getPrevious().breakForwardLink(); |