public class Watermark extends Object
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
}
Viewer,
PdfViewOptions,
Position| Constructor and Description |
|---|
Watermark(String text)
Initializes a new instance of the
Watermark class. |
| Modifier and Type | Method and Description |
|---|---|
Color |
getColor()
Returns the watermark color.
|
String |
getColorAsHex()
Returns the watermark color in hex format.
|
String |
getFontName()
Returns the font name used for the watermark.
|
Position |
getPosition()
Returns the watermark position.
|
Size |
getSize()
Returns the watermark size.
|
String |
getText()
Returns the watermark text.
|
void |
setColor(Color value)
Sets the watermark color.
|
void |
setColor(String colorName)
Sets the watermark color.
|
void |
setFontName(String value)
Sets the font name used for the watermark.
|
void |
setPosition(Position value)
Sets the watermark position.
|
void |
setSize(Size value)
Sets the watermark size.
|
public Watermark(String text)
Initializes a new instance of the Watermark class.
text - The watermark text.IllegalArgumentException - Thrown when the text parameter is null or empty.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().
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().
public final String getFontName()
Returns the font name used for the watermark.
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.
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.
public final String getText()
Returns the watermark text. This method retrieves the text of the watermark applied to the document.
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().
value - 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().
colorName - The watermark color to set.public final void setFontName(String value)
Sets the font name used for the watermark.
value - The font name used for the watermark.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.
value - The watermark position.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.
value - The watermark size.Copyright © 2025. All rights reserved.