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 textboxes with images.
Document doc = new Document(getMyDir() + "Shape.ReplaceTextboxesWithImages.doc");

// This gets a live collection of all shape nodes in the document.
NodeCollection shapeCollection = doc.getChildNodes(NodeType.SHAPE, true);

// Since we will be adding/removing nodes, it is better to copy all collection
// into a fixed size array, otherwise iterator will be invalidated.
Node[] shapes = shapeCollection.toArray();

for (Node node : shapes)
{
    Shape shape = (Shape) node;
    // Filter out all shapes that we don't need.
    if (shape.getShapeType() == ShapeType.TEXT_BOX)
    {
        // Create a new shape that will replace the existing shape.
        Shape image = new Shape(doc, ShapeType.IMAGE);

        // Load the image into the new shape.
        image.getImageData().setImage(getImageDir() + "Hammer.wmf");

        // Make new shape's position to match the old shape.
        image.setLeft(shape.getLeft());
        image.setTop(shape.getTop());
        image.setWidth(shape.getWidth());
        image.setHeight(shape.getHeight());
        image.setRelativeHorizontalPosition(shape.getRelativeHorizontalPosition());
        image.setRelativeVerticalPosition(shape.getRelativeVerticalPosition());
        image.setHorizontalAlignment(shape.getHorizontalAlignment());
        image.setVerticalAlignment(shape.getVerticalAlignment());
        image.setWrapType(shape.getWrapType());
        image.setWrapSide(shape.getWrapSide());

        // Insert new shape after the old shape and remove the old shape.
        shape.getParentNode().insertAfter(image, shape);
        shape.remove();
    }
}

doc.save(getMyDir() + "\\Artifacts\\Shape.ReplaceTextboxesWithImages.doc");
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.