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 |
|---|---|
WatermarkGeometry |
createGeometry(ContentPartGeometry parent) |
Watermark |
deepClone() |
Color |
getBackgroundColor()
Gets the background color of the text.
|
Color |
getBackgroundColorConsideringOpacity() |
Font |
getFont()
Gets the font of the text.
|
Color |
getForegroundColor()
Gets the foreground color of the text.
|
Color |
getForegroundColorConsideringOpacity() |
Thickness |
getPadding()
Gets the padding settings of this
. |
SizeD |
getSize() |
String |
getText()
Gets the text to be used as watermark.
|
int |
getTextAlignment()
Gets the watermark
. |
boolean |
hasSameValues(Watermark watermark) |
boolean |
isImageWatermark() |
boolean |
isTextWatermark() |
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 |
setPadding(Thickness value)
Sets the padding settings of this
. |
void |
setText(String value)
Sets the text to be used as watermark.
|
void |
setTextAlignment(int value)
Sets the watermark
. |
copyPropertiesValues, getConsiderParentMargins, getHeight, getHorizontalAlignment, getMargins, getOpacity, getPagesSetup, getRotateAngle, getScaleFactor, getSizingType, getTileOptions, getTransparency, getVerticalAlignment, getWidth, getX, getY, isBackground, setBackground, setConsiderParentMargins, setHeight, setHorizontalAlignment, setMargins, setOpacity, setPagesSetup, setRotateAngle, setScaleFactor, setSizingType, setTileOptions, setVerticalAlignment, setWidth, setX, setYpublic 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 WatermarkGeometry createGeometry(ContentPartGeometry parent)
createGeometry in class Watermarkpublic final Color getBackgroundColor()
Gets the background color of the text.
public final Color getBackgroundColorConsideringOpacity()
public final Font getFont()
Gets the font of the text.
public final Color getForegroundColor()
Gets the foreground color of the text.
public final Color getForegroundColorConsideringOpacity()
public final Thickness getPadding()
TextWatermark.
This property is applicable only to image files.TextWatermark.public final String getText()
Gets the text to be used as watermark.
public final int getTextAlignment()
TextAlignment.
Default value is .TextAlignment.Left
TextAlignment.public boolean hasSameValues(Watermark watermark)
hasSameValues in class Watermarkpublic boolean isImageWatermark()
isImageWatermark in class Watermarkpublic boolean isTextWatermark()
isTextWatermark in class Watermarkpublic final void setBackgroundColor(Color value)
Sets the background color of the text.
value - The background color of the text.public final void setFont(Font value)
Sets the font of the text.
value - The font 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 void setPadding(Thickness value)
TextWatermark.
This property is applicable only to image files.value - The padding settings of this TextWatermark.public final void setText(String value)
Sets the text to be used as watermark.
value - The string representing watermark text.public final void setTextAlignment(int value)
TextAlignment.
Default value is .TextAlignment.Left
value - The watermark TextAlignment.Copyright © 2026. All rights reserved.