com.aspose.words

Class TextBoxWrapMode

  • java.lang.Object
    • com.aspose.words.TextBoxWrapMode
public class TextBoxWrapMode 
extends java.lang.Object

Utility class containing constants. Specifies how text wraps inside a shape.

Example:

Shows how to insert text boxes and arrange their text.
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() + "Drawing.TextBox.docx");

Field Summary
static final intSQUARE = 0
Text wraps inside a shape.
static final intNONE = 2
Text does not wrap inside a shape.
 

    • Field Detail

      • SQUARE = 0

        public static final int SQUARE
        Text wraps inside a shape.
      • NONE = 2

        public static final int NONE
        Text does not wrap inside a shape.