com.groupdocs.watermark.watermarks

Class TextWatermark



  • 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 Detail

      • TextWatermark

        public TextWatermark(String text,
                     Font font)
        Initializes a new instance of the TextWatermark class with a specified text and a font.
        Parameters:
        text - The text to be used as watermark.
        font - The font of the text.
    • Method Detail

      • getText

        public final String getText()

        Gets the text to be used as watermark.

        Returns:
        The string representing watermark text.
      • setText

        public final void setText(String value)

        Sets the text to be used as watermark.

        Parameters:
        value - The string representing watermark text.
      • getFont

        public final Font getFont()

        Gets the font of the text.

        Returns:
        The font of the text.
      • setFont

        public final void setFont(Font value)

        Sets the font of the text.

        Parameters:
        value - The font of the text.
      • getForegroundColor

        public final Color getForegroundColor()

        Gets the foreground color of the text.

        Returns:
        The foreground color of the text.
      • setForegroundColor

        public final void setForegroundColor(Color value)

        Sets the foreground color of the text.

        Parameters:
        value - The foreground color of the text.
      • getBackgroundColor

        public final Color getBackgroundColor()

        Gets the background color of the text.

        Returns:
        The background color of the text.
      • setBackgroundColor

        public final void setBackgroundColor(Color value)

        Sets the background color of the text.

        Parameters:
        value - The background color of the text.