ImageWatermark class

ImageWatermark class

Represents an image watermark.

Learn more:

The ImageWatermark type exposes the following members:

Constructors

Constructor Description
init Initializes a new ImageWatermark instance with a specified file path.
init Initializes a new ImageWatermark with the provided image stream.

Methods

Method Description
dispose Disposes the current instance.

Properties

Property Description
consider_parent_margins The property indicating whether the watermark size and coordinates are calculated considering parent margins. If set to True, calculations consider parent margins; by default the value is False and parent margins are ignored. (inherited from Watermark)
height The desired height of this Watermark. (inherited from Watermark)
horizontal_alignment The horizontal alignment of this Watermark. (inherited from Watermark)
is_background The property indicating whether the watermark should be placed in the background. If true, the watermark is placed at the bottom; otherwise, it is placed at the top (default is False). (inherited from Watermark)
margins The margin settings of this Watermark. (inherited from Watermark)
opacity The opacity of this Watermark. (inherited from Watermark)
pages_setup The pages setup settings of this Watermark. (inherited from Watermark)
rotate_angle The rotate angle of this Watermark in degrees. (inherited from Watermark)
save_result_in_metadata The property indicates whether to save information about added watermarks in the document metadata. (inherited from Watermark)
scale_factor The scale factor of this Watermark, defining how watermark size depends on parent size. (inherited from Watermark)
sizing_type The sizing type of the watermark. (inherited from Watermark)
tile_options The options to define a repeated watermark. (inherited from Watermark)
vertical_alignment The vertical alignment of this Watermark. (inherited from Watermark)
width The desired width of this Watermark. (inherited from Watermark)
x The x-coordinate of this Watermark. (inherited from Watermark)
y The y-coordinate of this Watermark. (inherited from Watermark)

Example

import io
from groupdocs.watermark import Watermarker
from groupdocs.watermark.watermarks import ImageWatermark

def add_image_watermark_from_stream():
    # Load image data into a stream
    with open("./logo.png", "rb") as f:
        image_data = f.read()

    # Open the document and add the image watermark
    with Watermarker("./sample.docx") as watermarker:
        with ImageWatermark(stream=io.BytesIO(image_data)) as watermark:
            watermarker.add(watermark)
        watermarker.save("./output.docx")

Guides

Task guides that use ImageWatermark:

See Also