Package com.aspose.words

Examples of com.aspose.words.Shape


     */
    private static void insertWatermarkText(Document doc, String watermarkText) throws Exception
    {
        // Create a watermark shape. This will be a WordArt shape.
        // You are free to try other shape types as watermarks.
        Shape watermark = new Shape(doc, ShapeType.TEXT_PLAIN_TEXT);

        // Set up the text of the watermark.
        watermark.getTextPath().setText(watermarkText);
        watermark.getTextPath().setFontFamily("Arial");
        watermark.setWidth(500);
        watermark.setHeight(100);
        // Text will be directed from the bottom-left to the top-right corner.
        watermark.setRotation(-40);
        // Remove the following two lines if you need a solid black text.
        watermark.getFill().setColor(Color.GRAY); // Try LightGray to get more Word-style watermark
        watermark.setStrokeColor(Color.GRAY); // Try LightGray to get more Word-style watermark

        // Place the watermark in the page center.
        watermark.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
        watermark.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
        watermark.setWrapType(WrapType.NONE);
        watermark.setVerticalAlignment(VerticalAlignment.CENTER);
        watermark.setHorizontalAlignment(HorizontalAlignment.CENTER);

        // Create a new paragraph and append the watermark to this paragraph.
        Paragraph watermarkPara = new Paragraph(doc);
        watermarkPara.appendChild(watermark);

View Full Code Here


    // 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("data/background.jpg");

            // 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();
        }
View Full Code Here

TOP

Related Classes of com.aspose.words.Shape

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.