com.aspose.words

Class RelativeVerticalPosition

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

Utility class containing constants. Specifies to what the vertical position of a shape or text frame is relative.

Example:

Shows how to insert a floating image in the middle of a page.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// By default, the image is inline
Shape shape = builder.insertImage(getImageDir() + "Logo.jpg");

// Make the image float, put it behind text and center on the page
shape.setWrapType(WrapType.NONE);
shape.setBehindText(true);
shape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
shape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
shape.setHorizontalAlignment(HorizontalAlignment.CENTER);
shape.setVerticalAlignment(VerticalAlignment.CENTER);

doc.save(getArtifactsDir() + "Image.CreateFloatingPageCenter.docx");

Example:

Shows how to insert an image, and use it as a watermark.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert the image into the header so that it will be visible on every page.
BufferedImage image = ImageIO.read(new File(getImageDir() + "Transparent background logo.png"));
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
Shape shape = builder.insertImage(image);
shape.setWrapType(WrapType.NONE);
shape.setBehindText(true);

// Place the image at the center of the page.
shape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
shape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
shape.setLeft((builder.getPageSetup().getPageWidth() - shape.getWidth()) / 2.0);
shape.setTop((builder.getPageSetup().getPageHeight() - shape.getHeight()) / 2.0);

doc.save(getArtifactsDir() + "DocumentBuilder.InsertWatermark.docx");
See Also:
ShapeBase.RelativeVerticalPosition

Field Summary
static final intMARGIN = 0
Specifies that the vertical positioning shall be relative to the page margins.
static final intPAGE = 1
The object is positioned relative to the top edge of the page.
static final intPARAGRAPH = 2
The object is positioned relative to the top of the paragraph that contains the anchor.
static final intLINE = 3
Undocumented.
static final intTOP_MARGIN = 4
Specifies that the vertical positioning shall be relative to the top margin of the current page.
static final intBOTTOM_MARGIN = 5
Specifies that the vertical positioning shall be relative to the bottom margin of the current page.
static final intINSIDE_MARGIN = 6
Specifies that the vertical positioning shall be relative to the inside margin of the current page.
static final intOUTSIDE_MARGIN = 7
Specifies that the vertical positioning shall be relative to the outside margin of the current page.
static final intTABLE_DEFAULT = 0
Default value is MARGIN.
static final intTEXT_FRAME_DEFAULT = 2
Default value is PARAGRAPH.
 

    • Field Detail

      • MARGIN = 0

        public static final int MARGIN
        Specifies that the vertical positioning shall be relative to the page margins.
      • PAGE = 1

        public static final int PAGE
        The object is positioned relative to the top edge of the page.
      • PARAGRAPH = 2

        public static final int PARAGRAPH
        The object is positioned relative to the top of the paragraph that contains the anchor.
      • LINE = 3

        public static final int LINE
        Undocumented.
      • TOP_MARGIN = 4

        public static final int TOP_MARGIN
        Specifies that the vertical positioning shall be relative to the top margin of the current page.
      • BOTTOM_MARGIN = 5

        public static final int BOTTOM_MARGIN
        Specifies that the vertical positioning shall be relative to the bottom margin of the current page.
      • INSIDE_MARGIN = 6

        public static final int INSIDE_MARGIN
        Specifies that the vertical positioning shall be relative to the inside margin of the current page.
      • OUTSIDE_MARGIN = 7

        public static final int OUTSIDE_MARGIN
        Specifies that the vertical positioning shall be relative to the outside margin of the current page.
      • TABLE_DEFAULT = 0

        public static final int TABLE_DEFAULT
        Default value is MARGIN.
      • TEXT_FRAME_DEFAULT = 2

        public static final int TEXT_FRAME_DEFAULT
        Default value is PARAGRAPH.