public class TextBoxWrapMode
Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a shape that contains a TextBox
Shape textBoxShape = builder.insertShape(ShapeType.TEXT_BOX, 150.0, 100.0);
TextBox textBox = textBoxShape.getTextBox();
// Move the document builder to inside the TextBox and write text
builder.moveTo(textBoxShape.getLastParagraph());
builder.write("Vertical text");
// Text is displayed vertically, written top to bottom
textBox.setLayoutFlow(LayoutFlow.TOP_TO_BOTTOM_IDEOGRAPHIC);
// Move the builder out of the shape and back into the main document body
builder.moveTo(textBoxShape.getParentParagraph());
// Insert another TextBox
textBoxShape = builder.insertShape(ShapeType.TEXT_BOX, 150.0, 100.0);
textBox = textBoxShape.getTextBox();
// Apply these values to both these members to get the parent shape to defy the dimensions we set to fit tightly around the TextBox's text
textBox.setFitShapeToText(true);
textBox.setTextBoxWrapMode(TextBoxWrapMode.NONE);
builder.moveTo(textBoxShape.getLastParagraph());
builder.write("Text fit tightly inside textbox");
builder.moveTo(textBoxShape.getParentParagraph());
textBoxShape = builder.insertShape(ShapeType.TEXT_BOX, 100.0, 100.0);
textBox = textBoxShape.getTextBox();
// Set margins for the textbox
textBox.setInternalMarginTop(15.0);
textBox.setInternalMarginBottom(15.0);
textBox.setInternalMarginLeft(15.0);
textBox.setInternalMarginRight(15.0);
builder.moveTo(textBoxShape.getLastParagraph());
builder.write("Text placed according to textbox margins");
doc.save(getArtifactsDir() + "Shape.TextBox.docx");
Field Summary | ||
---|---|---|
static final int | SQUARE | |
Text wraps inside a shape.
|
||
static final int | NONE | |
Text does not wrap inside a shape.
|