TextWatermark
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();
Constructors
| 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. |
Methods
| 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) |
TextWatermark(String text, Font font)
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. |
getText()
public final String getText()
Gets the text to be used as watermark.
Returns: java.lang.String - The string representing watermark text.
setText(String value)
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. |
getFont()
public final Font getFont()
Gets the font of the text.
Returns: Font - The font of the text.
setFont(Font value)
public final void setFont(Font value)
Sets the font of the text.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | Font | The font of the text. |
getForegroundColor()
public final Color getForegroundColor()
Gets the foreground color of the text.
Returns: Color - The foreground color of the text.
setForegroundColor(Color value)
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. |
getBackgroundColor()
public final Color getBackgroundColor()
Gets the background color of the text.
Returns: Color - The background color of the text.
setBackgroundColor(Color value)
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. |
getTextAlignment()
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).
setTextAlignment(int value)
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). |
isImageWatermark()
public boolean isImageWatermark()
Returns: boolean
isTextWatermark()
public boolean isTextWatermark()
Returns: boolean
getForegroundColorConsideringOpacity()
public final Color getForegroundColorConsideringOpacity()
Returns: Color
getBackgroundColorConsideringOpacity()
public final Color getBackgroundColorConsideringOpacity()
Returns: Color
getSize()
public SizeD getSize()
Returns: SizeD
getPadding()
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).
setPadding(Thickness value)
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). |
deepClone()
public Watermark deepClone()
Returns: Watermark
hasSameValues(Watermark watermark)
public boolean hasSameValues(Watermark watermark)
Parameters:
| Parameter | Type | Description |
|---|---|---|
| watermark | Watermark |
Returns: boolean
createGeometry(ContentPartGeometry parent)
public WatermarkGeometry createGeometry(ContentPartGeometry parent)
Parameters:
| Parameter | Type | Description |
|---|---|---|
| parent | ContentPartGeometry |
Returns: WatermarkGeometry