Bekerja dengan TextBoxesTertaut
Dalam Aspose.Words, kelas TextBox digunakan untuk menentukan bagaimana teks ditampilkan di dalam bentuk. Ini menyediakan properti publik bernama Parent untuk mendapatkan bentuk parent untuk kotak teks agar pelanggan dapat menemukan linked Shape dari linked TextBox.
Buat Tautan
Kelas TextBox menyediakan metode IsValidLinkTarget untuk memeriksa apakah TextBox dapat ditautkan ke target Textbox.
Contoh kode berikut menunjukkan cara memeriksa apakah TextBox
dapat ditautkan ke Kotak Teks target:
// 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); |
Periksa Urutan TextBox
Ada beberapa cara untuk menampilkan teks dalam bentuk. TextBox dapat berupa Kepala, Tengah, atau Ekor dari suatu barisan.
Contoh kode berikut menunjukkan cara memeriksa apakah TextBox adalah Kepala, Ekor, atau Bagian Tengah urutan:
// 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."); | |
} |
Putuskan Tautan
Dengan menggunakan metode BreakForwardLink, Anda dapat memutuskan tautan ke TextBox berikutnya.
Contoh kode berikut menunjukkan cara memutuskan tautan untuk 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(); |