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 a watermark image into a document using DocumentBuilder.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// The best place for the watermark image is in the header or footer so it is shown on every page
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
BufferedImage image = ImageIO.read(new File(getImageDir() + "Transparent background logo.png"));
// Insert a floating picture
Shape shape = builder.insertImage(image);
shape.setWrapType(WrapType.NONE);
shape.setBehindText(true);
shape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
shape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
// Calculate image left and top position so it appears in the center of the 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 int | MARGIN = 0 | |
Specifies that the vertical positioning shall be relative to the page margins.
|
static final int | PAGE = 1 | |
The object is positioned relative to the top edge of the page.
|
static final int | PARAGRAPH = 2 | |
The object is positioned relative to the top of the paragraph that contains the anchor.
|
static final int | LINE = 3 | |
Undocumented.
|
static final int | TOP_MARGIN = 4 | |
Specifies that the vertical positioning shall be relative to the top margin of the current page.
|
static final int | BOTTOM_MARGIN = 5 | |
Specifies that the vertical positioning shall be relative to the bottom margin of the current page.
|
static final int | INSIDE_MARGIN = 6 | |
Specifies that the vertical positioning shall be relative to the inside margin of the current page.
|
static final int | OUTSIDE_MARGIN = 7 | |
Specifies that the vertical positioning shall be relative to the outside margin of the current page.
|
static final int | TABLE_DEFAULT = 0 | |
Default value is MARGIN.
|
static final int | TEXT_FRAME_DEFAULT = 2 | |
Default value is PARAGRAPH.
|
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.
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.