public class TextWatermark extends Watermark
Learn more:
The following example demonstrates how to scale the text watermark depending on the parent size.
Watermarker watermarker = new Watermarker("C:\\test.some_ext"); TextWatermark watermark = new TextWatermark("test watermark", new Font("Arial", 36)); watermark.setHorizontalAlignment(HorizontalAlignment.Center); watermark.setVerticalAlignment(VerticalAlignment.Center); watermark.setSizingType(SizingType.ScaleToParentDimensions); watermark.setRotateAngle(45); watermark.setScaleFactor(0.4); watermarker.add(watermark); watermarker.save("C:\\modified_test.some_ext"); watermarker.close();
Constructor and Description |
---|
TextWatermark(String text,
Font font)
Initializes a new instance of the
class with a specified text and a font. |
Modifier and Type | Method and Description |
---|---|
Color |
getBackgroundColor()
Gets the background color of the text.
|
Font |
getFont()
Gets the font of the text.
|
Color |
getForegroundColor()
Gets the foreground color of the text.
|
String |
getText()
Gets the text to be used as watermark.
|
int |
getTextAlignment()
Gets the watermark
. |
void |
setBackgroundColor(Color value)
Sets the background color of the text.
|
void |
setFont(Font value)
Sets the font of the text.
|
void |
setForegroundColor(Color value)
Sets the foreground color of the text.
|
void |
setText(String value)
Sets the text to be used as watermark.
|
void |
setTextAlignment(int value)
Sets the watermark
. |
getConsiderParentMargins, getHeight, getHorizontalAlignment, getMargins, getOpacity, getRotateAngle, getScaleFactor, getSizingType, getVerticalAlignment, getWidth, getX, getY, isBackground, setBackground, setConsiderParentMargins, setHeight, setHorizontalAlignment, setMargins, setOpacity, setRotateAngle, setScaleFactor, setSizingType, setVerticalAlignment, setWidth, setX, setY
public TextWatermark(String text, Font font)
TextWatermark
class with a specified text and a font.text
- The text to be used as watermark.font
- The font of the text.public final String getText()
Gets the text to be used as watermark.
public final void setText(String value)
Sets the text to be used as watermark.
value
- The string representing watermark text.public final Font getFont()
Gets the font of the text.
public final void setFont(Font value)
Sets the font of the text.
value
- The font of the text.public final Color getForegroundColor()
Gets the foreground color of the text.
public final void setForegroundColor(Color value)
Sets the foreground color of the text.
value
- The foreground color of the text.public final Color getBackgroundColor()
Gets the background color of the text.
public final void setBackgroundColor(Color value)
Sets the background color of the text.
value
- The background color of the text.public final int getTextAlignment()
TextAlignment
.
Default value is
.TextAlignment.Left
TextAlignment
.public final void setTextAlignment(int value)
TextAlignment
.
Default value is
.TextAlignment.Left
value
- The watermark TextAlignment
.