リンクされたTextBoxesでの作業
Aspose.Wordsでは、TextBoxクラスを使用して、図形内のテキストの表示方法を指定します。 これはParentという名前のパブリックプロパティを提供し、顧客がlinkedTextBoxからlinkedShapeを見つけることができるように、テキストボックスの親図形を取得します。
リンクを作成する
TextBoxクラスは、TextBoxをターゲットTextboxにリンクできるかどうかを確認するためにIsValidLinkTargetメソッドを提供します。
次のコード例は、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(); |