com.aspose.words

Class WrapSide

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

Utility class containing constants. Specifies what side(s) of the shape or picture the text wraps around.

Example:

Shows how to replace all textbox shapes with image shapes.
Document doc = new Document(getMyDir() + "Textboxes in drawing canvas.docx");

List<Shape> shapeList = Arrays.stream(doc.getChildNodes(NodeType.SHAPE, true).toArray())
        .filter(Shape.class::isInstance)
        .map(Shape.class::cast)
        .collect(Collectors.toList());

Assert.assertEquals(3, IterableUtils.countMatches(shapeList, s -> s.getShapeType() == ShapeType.TEXT_BOX));
Assert.assertEquals(1, IterableUtils.countMatches(shapeList, s -> s.getShapeType() == ShapeType.IMAGE));

for (Shape shape : shapeList) {
    if (((shape.getShapeType()) == (ShapeType.TEXT_BOX))) {
        Shape replacementShape = new Shape(doc, ShapeType.IMAGE);
        replacementShape.getImageData().setImage(getImageDir() + "Logo.jpg");
        replacementShape.setLeft(shape.getLeft());
        replacementShape.setTop(shape.getTop());
        replacementShape.setWidth(shape.getWidth());
        replacementShape.setHeight(shape.getHeight());
        replacementShape.setRelativeHorizontalPosition(shape.getRelativeHorizontalPosition());
        replacementShape.setRelativeVerticalPosition(shape.getRelativeVerticalPosition());
        replacementShape.setHorizontalAlignment(shape.getHorizontalAlignment());
        replacementShape.setVerticalAlignment(shape.getVerticalAlignment());
        replacementShape.setWrapType(shape.getWrapType());
        replacementShape.setWrapSide(shape.getWrapSide());

        shape.getParentNode().insertAfter(replacementShape, shape);
        shape.remove();
    }
}

shapeList = Arrays.stream(doc.getChildNodes(NodeType.SHAPE, true).toArray())
        .filter(Shape.class::isInstance)
        .map(Shape.class::cast)
        .collect(Collectors.toList());

Assert.assertEquals(0, IterableUtils.countMatches(shapeList, s -> s.getShapeType() == ShapeType.TEXT_BOX));
Assert.assertEquals(4, IterableUtils.countMatches(shapeList, s -> s.getShapeType() == ShapeType.IMAGE));

doc.save(getArtifactsDir() + "Shape.ReplaceTextboxesWithImages.docx");
See Also:
ShapeBase.WrapSide

Field Summary
static final intBOTH = 0
The document text wraps on both sides of the shape.
static final intLEFT = 1
The document text wraps on the left side of the shape only. There is a text free area on the right of the shape.
static final intRIGHT = 2
The document text wraps on the right side of the shape only. There is a text free area on the left side of the shape.
static final intLARGEST = 3
The document text wraps on the side of the shape that is farthest from the page margin, leaving text free area on the other side of the shape.
static final intDEFAULT = 0
Default value is BOTH.
 

    • Field Detail

      • BOTH = 0

        public static final int BOTH
        The document text wraps on both sides of the shape.
      • LEFT = 1

        public static final int LEFT
        The document text wraps on the left side of the shape only. There is a text free area on the right of the shape.
      • RIGHT = 2

        public static final int RIGHT
        The document text wraps on the right side of the shape only. There is a text free area on the left side of the shape.
      • LARGEST = 3

        public static final int LARGEST
        The document text wraps on the side of the shape that is farthest from the page margin, leaving text free area on the other side of the shape.
      • DEFAULT = 0

        public static final int DEFAULT
        Default value is BOTH.