public class RelativeVerticalPosition
extends java.lang.Object
Examples:
Shows how to insert a floating image to the center of a page.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a floating image that will appear behind the overlapping text and align it to the page's center.
Shape shape = builder.insertImage(getImageDir() + "Logo.jpg");
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");
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.
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
Shape shape = builder.insertImage(getImageDir() + "Transparent background logo.png");
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");
| Modifier and Type | Field and Description |
|---|---|
static int |
BOTTOM_MARGIN
Specifies that the vertical positioning shall be relative to the bottom margin of the current page.
|
static int |
INSIDE_MARGIN
Specifies that the vertical positioning shall be relative to the inside margin of the current page.
|
static int |
length |
static int |
LINE
Undocumented.
|
static int |
MARGIN
Specifies that the vertical positioning shall be relative to the page margins.
|
static int |
OUTSIDE_MARGIN
Specifies that the vertical positioning shall be relative to the outside margin of the current page.
|
static int |
PAGE
The object is positioned relative to the top edge of the page.
|
static int |
PARAGRAPH
The object is positioned relative to the top of the paragraph that contains the anchor.
|
static int |
TABLE_DEFAULT
Default value is
MARGIN. |
static int |
TEXT_FRAME_DEFAULT
Default value is
PARAGRAPH. |
static int |
TOP_MARGIN
Specifies that the vertical positioning shall be relative to the top margin of the current page.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
fromName(java.lang.String relativeVerticalPositionName) |
static java.lang.String |
getName(int relativeVerticalPosition) |
static int[] |
getValues() |
static java.lang.String |
toString(int relativeVerticalPosition) |
public static int MARGIN
public static int PAGE
public static int PARAGRAPH
public static int LINE
public static int TOP_MARGIN
public static int BOTTOM_MARGIN
public static int INSIDE_MARGIN
public static int OUTSIDE_MARGIN
public static int TABLE_DEFAULT
MARGIN.public static int TEXT_FRAME_DEFAULT
PARAGRAPH.public static int length