public class RelativeVerticalPosition
Example: Example:
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");
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");
Field Summary | ||
---|---|---|
static final int | MARGIN | |
Specifies that the vertical positioning shall be relative to the page margins.
|
||
static final int | PAGE | |
The object is positioned relative to the top edge of the page.
|
||
static final int | PARAGRAPH | |
The object is positioned relative to the top of the paragraph that contains the anchor.
|
||
static final int | LINE | |
Undocumented.
|
||
static final int | TOP_MARGIN | |
Specifies that the vertical positioning shall be relative to the top margin of the current page.
|
||
static final int | BOTTOM_MARGIN | |
Specifies that the vertical positioning shall be relative to the bottom margin of the current page.
|
||
static final int | INSIDE_MARGIN | |
Specifies that the vertical positioning shall be relative to the inside margin of the current page.
|
||
static final int | OUTSIDE_MARGIN | |
Specifies that the vertical positioning shall be relative to the outside margin of the current page.
|
||
static final int | TABLE_DEFAULT | |
Default value is |
||
static final int | TEXT_FRAME_DEFAULT | |
Default value is |
public static final int MARGIN
public static final int PAGE
public static final int PARAGRAPH
public static final int LINE
public static final int TOP_MARGIN
public static final int BOTTOM_MARGIN
public static final int INSIDE_MARGIN
public static final int OUTSIDE_MARGIN
public static final int TABLE_DEFAULT
public static final int TEXT_FRAME_DEFAULT