TextWatermark
Leave feedback
On this page
Inheritance: java.lang.Object, com.groupdocs.watermark.Watermark
public class TextWatermark extends Watermark
Represents a text 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 | Description |
|---|---|
| TextWatermark(String text, Font font) | Initializes a new instance of the [TextWatermark](../../com.groupdocs.watermark.watermarks/textwatermark) class with a specified text and a font. |
| Method | Description |
|---|---|
| getText() | Gets the text to be used as watermark. |
| setText(String value) | Sets the text to be used as watermark. |
| getFont() | Gets the font of the text. |
| setFont(Font value) | Sets the font of the text. |
| getForegroundColor() | Gets the foreground color of the text. |
| setForegroundColor(Color value) | Sets the foreground color of the text. |
| getBackgroundColor() | Gets the background color of the text. |
| setBackgroundColor(Color value) | Sets the background color of the text. |
| getTextAlignment() | Gets the watermark [TextAlignment](../../com.groupdocs.watermark.watermarks/textalignment). |
| setTextAlignment(int value) | Sets the watermark [TextAlignment](../../com.groupdocs.watermark.watermarks/textalignment). |
| isImageWatermark() | |
| isTextWatermark() | |
| getForegroundColorConsideringOpacity() | |
| getBackgroundColorConsideringOpacity() | |
| getSize() | |
| getPadding() | Gets the padding settings of this [TextWatermark](../../com.groupdocs.watermark.watermarks/textwatermark). |
| setPadding(Thickness value) | Sets the padding settings of this [TextWatermark](../../com.groupdocs.watermark.watermarks/textwatermark). |
| deepClone() | |
| hasSameValues(Watermark watermark) | |
| createGeometry(ContentPartGeometry parent) |
public TextWatermark(String text, Font font)
Initializes a new instance of the [TextWatermark](../../com.groupdocs.watermark.watermarks/textwatermark) class with a specified text and a font.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| text | java.lang.String | The text to be used as watermark. |
| font | Font | The font of the text. |
public final String getText()
Gets the text to be used as watermark.
Returns: java.lang.String - The string representing watermark text.
public final void setText(String value)
Sets the text to be used as watermark.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | java.lang.String | The string representing watermark text. |
public final Font getFont()
Gets the font of the text.
Returns: Font - The font of the text.
public final void setFont(Font value)
Sets the font of the text.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | Font | The font of the text. |
public final Color getForegroundColor()
Gets the foreground color of the text.
Returns: Color - The foreground color of the text.
public final void setForegroundColor(Color value)
Sets the foreground color of the text.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | Color | The foreground color of the text. |
public final Color getBackgroundColor()
Gets the background color of the text.
Returns: Color - The background color of the text.
public final void setBackgroundColor(Color value)
Sets the background color of the text.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | Color | The background color of the text. |
public final int getTextAlignment()
Gets the watermark [TextAlignment](../../com.groupdocs.watermark.watermarks/textalignment).
Default value is [TextAlignment.Left](../../com.groupdocs.watermark.watermarks/textalignment#Left).
Returns:
int - The watermark [TextAlignment](../../com.groupdocs.watermark.watermarks/textalignment).
public final void setTextAlignment(int value)
Sets the watermark [TextAlignment](../../com.groupdocs.watermark.watermarks/textalignment).
Default value is [TextAlignment.Left](../../com.groupdocs.watermark.watermarks/textalignment#Left).
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | int | The watermark [TextAlignment](../../com.groupdocs.watermark.watermarks/textalignment). |
public boolean isImageWatermark()
Returns: boolean
public boolean isTextWatermark()
Returns: boolean
public final Color getForegroundColorConsideringOpacity()
Returns: Color
public final Color getBackgroundColorConsideringOpacity()
Returns: Color
public SizeD getSize()
Returns: SizeD
public final Thickness getPadding()
Gets the padding settings of this [TextWatermark](../../com.groupdocs.watermark.watermarks/textwatermark). This property is applicable only to image files.
Returns:
Thickness - The padding settings of this [TextWatermark](../../com.groupdocs.watermark.watermarks/textwatermark).
public final void setPadding(Thickness value)
Sets the padding settings of this [TextWatermark](../../com.groupdocs.watermark.watermarks/textwatermark). This property is applicable only to image files.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | Thickness | The padding settings of this [TextWatermark](../../com.groupdocs.watermark.watermarks/textwatermark). |
public Watermark deepClone()
Returns: Watermark
public boolean hasSameValues(Watermark watermark)
Parameters:
| Parameter | Type | Description |
|---|---|---|
| watermark | Watermark |
Returns: boolean
public WatermarkGeometry createGeometry(ContentPartGeometry parent)
Parameters:
| Parameter | Type | Description |
|---|---|---|
| parent | ContentPartGeometry |
Returns: WatermarkGeometry
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.