Watermark
Leave feedback
On this page
Inheritance: java.lang.Object
public class Watermark
Represents a text watermark. For details, see the documentation.
The Watermark class represents a text watermark in the GroupDocs.Viewer component. It is used to define and apply a watermark to the rendered output of documents.
Example usage:
Watermark watermark = new Watermark("Watermark");
watermark.setPosition(Position.DIAGONAL);
watermark.setColor(java.awt.Color.GREEN);
watermark.setSize(Size.HALF_SIZE);
PdfViewOptions pdfViewOptions = new PdfViewOptions();
pdfViewOptions.setWatermark(watermark);
try (Viewer viewer = new Viewer("document.docx")) {
viewer.view(pdfViewOptions);
// Use the viewer object for further operations
}
| Constructor | Description |
|---|---|
| Watermark(String text) | Initializes a new instance of the Watermark class. |
| Method | Description |
|---|---|
| getText() | Returns the watermark text. |
| getColor() | Returns the watermark color. |
| getColorAsHex() | Returns the watermark color in hex format. |
| setColor(Color value) | Sets the watermark color. |
| setColor(String colorName) | Sets the watermark color. |
| getPosition() | Returns the watermark position. |
| setPosition(Position value) | Sets the watermark position. |
| getSize() | Returns the watermark size. |
| setSize(Size value) | Sets the watermark size. |
| getFontName() | Returns the font name used for the watermark. |
| setFontName(String value) | Sets the font name used for the watermark. |
public Watermark(String text)
Initializes a new instance of the Watermark class.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| text | java.lang.String | The watermark text. |
public final String getText()
Returns the watermark text. This method retrieves the text of the watermark applied to the document.
Returns: java.lang.String - the watermark text.
public final Color getColor()
Returns the watermark color. This method retrieves the color of the watermark applied to the document.
Note: The default value is the red color obtained from Color#getRed().getRed().
Returns: java.awt.Color - the watermark color.
public final String getColorAsHex()
Returns the watermark color in hex format. This method retrieves the color of the watermark applied to the document.
Note: The default value is the red color obtained from Color#getRed().getRed().
Returns: java.lang.String - the watermark color in hex format.
public final void setColor(Color value)
Sets the watermark color. This method sets the color of the watermark applied to the document.
Note: The default value is obtained from Color#getRed().getRed().
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | java.awt.Color | The watermark color to set. |
public final void setColor(String colorName)
Sets the watermark color. This method sets the color of the watermark applied to the document.
Note: The default value is obtained from Color#getRed().getRed().
Parameters:
| Parameter | Type | Description |
|---|---|---|
| colorName | java.lang.String | The watermark color to set. |
public final Position getPosition()
Returns the watermark position. This method returns the position of the watermark applied to the document.
Note: The default value is Position.DIAGONAL.
Returns: Position - the watermark position.
public final void setPosition(Position value)
Sets the watermark position. This method sets the position of the watermark applied to the document.
Note: The default value is Position.DIAGONAL.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | Position | The watermark position. |
public final Size getSize()
Returns the watermark size. This method retrieves the size of the watermark applied to the document.
Note: The default value is Size.FULL_SIZE.
Returns: Size - the watermark size.
public final void setSize(Size value)
Sets the watermark size. This method sets the size of the watermark to be applied to the document.
Note: The default value is Size.FULL_SIZE.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | Size | The watermark size. |
public final String getFontName()
Returns the font name used for the watermark.
Returns: java.lang.String - the font name used for the watermark.
public final void setFontName(String value)
Sets the font name used for the watermark.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | java.lang.String | The font name used for the watermark. |
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.