public class WrapType
Example: Example:
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");
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 | NONE | |
No text wrapping around the shape. The shape is placed behind or in front of text.
|
||
static final int | INLINE | |
The shape remains on the same layer as text and treated as a character.
|
||
static final int | TOP_BOTTOM | |
The text stops at the top of the shape and restarts on the line below the shape.
|
||
static final int | SQUARE | |
Wraps text around all sides of the square bounding box of the shape.
|
||
static final int | TIGHT | |
Wraps tightly around the edges of the shape, instead of wrapping around the bounding box.
|
||
static final int | THROUGH | |
Same as Tight, but wraps inside any parts of the shape that are open.
|
public static final int NONE
public static final int INLINE
public static final int TOP_BOTTOM
public static final int SQUARE
public static final int TIGHT
public static final int THROUGH