Watermark

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
 }
 

Constructors

Constructor Description
Watermark(String text) Initializes a new instance of the Watermark class.

Methods

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.

Watermark(String text)

public Watermark(String text)

Initializes a new instance of the Watermark class.

Parameters:

Parameter Type Description
text java.lang.String The watermark text.

getText()

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.

getColor()

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.

getColorAsHex()

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.

setColor(Color value)

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.

setColor(String colorName)

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.

getPosition()

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.

setPosition(Position value)

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.

getSize()

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.

setSize(Size value)

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.

getFontName()

public final String getFontName()

Returns the font name used for the watermark.

Returns: java.lang.String - the font name used for the watermark.

setFontName(String value)

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.