set_watermark_to_images method

set_watermark_to_images(input_file_name, save_options, watermark_text)

Adds a text watermark into the document with options. Renders the output to images.

def set_watermark_to_images(self, input_file_name: str, save_options: aspose.words.saving.ImageSaveOptions, watermark_text: str):
    ...
ParameterTypeDescription
input_file_namestrThe input file name.
save_optionsImageSaveOptionsThe save options.
watermark_textstrText that is displayed as a watermark.

set_watermark_to_images(input_file_name, save_options, watermark_text, options)

Adds a text watermark into the document with options. Renders the output to images.

def set_watermark_to_images(self, input_file_name: str, save_options: aspose.words.saving.ImageSaveOptions, watermark_text: str, options: aspose.words.TextWatermarkOptions):
    ...
ParameterTypeDescription
input_file_namestrThe input file name.
save_optionsImageSaveOptionsThe save options.
watermark_textstrText that is displayed as a watermark.
optionsTextWatermarkOptionsDefines additional options for the text watermark.

set_watermark_to_images(input_stream, save_options, watermark_text)

Adds a text watermark into the document with options. Renders the output to images.

def set_watermark_to_images(self, input_stream: io.BytesIO, save_options: aspose.words.saving.ImageSaveOptions, watermark_text: str):
    ...
ParameterTypeDescription
input_streamio.BytesIOThe input file stream.
save_optionsImageSaveOptionsThe save options.
watermark_textstrText that is displayed as a watermark.

set_watermark_to_images(input_stream, save_options, watermark_text, options)

Adds a text watermark into the document with options. Renders the output to images.

def set_watermark_to_images(self, input_stream: io.BytesIO, save_options: aspose.words.saving.ImageSaveOptions, watermark_text: str, options: aspose.words.TextWatermarkOptions):
    ...
ParameterTypeDescription
input_streamio.BytesIOThe input file stream.
save_optionsImageSaveOptionsThe save options.
watermark_textstrText that is displayed as a watermark.
optionsTextWatermarkOptionsDefines additional options for the text watermark.

set_watermark_to_images(input_file_name, save_options, watermark_image_bytes)

Adds an image watermark into the document with options. Renders the output to images.

def set_watermark_to_images(self, input_file_name: str, save_options: aspose.words.saving.ImageSaveOptions, watermark_image_bytes: bytes):
    ...
ParameterTypeDescription
input_file_namestrThe input file name.
save_optionsImageSaveOptionsThe save options.
watermark_image_bytesbytesImage bytes that is displayed as a watermark.

set_watermark_to_images(input_file_name, save_options, watermark_image_bytes, options)

Adds an image watermark into the document with options. Renders the output to images.

def set_watermark_to_images(self, input_file_name: str, save_options: aspose.words.saving.ImageSaveOptions, watermark_image_bytes: bytes, options: aspose.words.ImageWatermarkOptions):
    ...
ParameterTypeDescription
input_file_namestrThe input file name.
save_optionsImageSaveOptionsThe save options.
watermark_image_bytesbytesImage bytes that is displayed as a watermark.
optionsImageWatermarkOptionsDefines additional options for the image watermark.

set_watermark_to_images(input_stream, save_options, watermark_image_stream)

Adds an image watermark into the document with options. Renders the output to images.

def set_watermark_to_images(self, input_stream: io.BytesIO, save_options: aspose.words.saving.ImageSaveOptions, watermark_image_stream: io.BytesIO):
    ...
ParameterTypeDescription
input_streamio.BytesIOThe input stream.
save_optionsImageSaveOptionsThe save options.
watermark_image_streamio.BytesIOImage stream that is displayed as a watermark.

set_watermark_to_images(input_stream, save_options, watermark_image_stream, options)

Adds an image watermark into the document with options. Renders the output to images.

def set_watermark_to_images(self, input_stream: io.BytesIO, save_options: aspose.words.saving.ImageSaveOptions, watermark_image_stream: io.BytesIO, options: aspose.words.ImageWatermarkOptions):
    ...
ParameterTypeDescription
input_streamio.BytesIOThe input stream.
save_optionsImageSaveOptionsThe save options.
watermark_image_streamio.BytesIOImage stream that is displayed as a watermark.
optionsImageWatermarkOptionsDefines additional options for the image watermark.

Examples

Shows how to insert watermark text to the document and save result to images.

doc = MY_DIR + 'Big document.docx'
watermark_text = 'This is a watermark'
images = aw.lowcode.Watermarker.set_watermark_to_images(input_file_name=doc, save_options=aw.saving.ImageSaveOptions(aw.SaveFormat.PNG), watermark_text=watermark_text)
watermark_options = aw.TextWatermarkOptions()
watermark_options.color = aspose.pydrawing.Color.red
images = aw.lowcode.Watermarker.set_watermark_to_images(input_file_name=doc, save_options=aw.saving.ImageSaveOptions(aw.SaveFormat.PNG), watermark_text=watermark_text, options=watermark_options)

Shows how to insert watermark text to the document from the stream and save result to images.

watermark_text = 'This is a watermark'
with system_helper.io.FileStream(MY_DIR + 'Document.docx', system_helper.io.FileMode.OPEN, system_helper.io.FileAccess.READ) as stream_in:
    images = aw.lowcode.Watermarker.set_watermark_to_images(input_stream=stream_in, save_options=aw.saving.ImageSaveOptions(aw.SaveFormat.PNG), watermark_text=watermark_text)
    watermark_options = aw.TextWatermarkOptions()
    watermark_options.color = aspose.pydrawing.Color.red
    images = aw.lowcode.Watermarker.set_watermark_to_images(input_stream=stream_in, save_options=aw.saving.ImageSaveOptions(aw.SaveFormat.PNG), watermark_text=watermark_text, options=watermark_options)

Shows how to insert watermark image to the document and save result to images.

doc = MY_DIR + 'Document.docx'
watermark_image = IMAGE_DIR + 'Logo.jpg'
aw.lowcode.Watermarker.set_watermark_to_images(input_file_name=doc, save_options=aw.saving.ImageSaveOptions(aw.SaveFormat.PNG), watermark_image_bytes=system_helper.io.File.read_all_bytes(watermark_image))
options = aw.ImageWatermarkOptions()
options.scale = 50
aw.lowcode.Watermarker.set_watermark_to_images(input_file_name=doc, save_options=aw.saving.ImageSaveOptions(aw.SaveFormat.PNG), watermark_image_bytes=system_helper.io.File.read_all_bytes(watermark_image), options=options)

Shows how to insert watermark image to the document from a stream and save result to images.

watermark_image = IMAGE_DIR + 'Logo.jpg'
with system_helper.io.FileStream(MY_DIR + 'Document.docx', system_helper.io.FileMode.OPEN, system_helper.io.FileAccess.READ) as stream_in:
    with system_helper.io.FileStream(watermark_image, system_helper.io.FileMode.OPEN, system_helper.io.FileAccess.READ) as image_stream:
        aw.lowcode.Watermarker.set_watermark_to_images(input_stream=stream_in, save_options=aw.saving.ImageSaveOptions(aw.SaveFormat.PNG), watermark_image_stream=image_stream)
        options = aw.ImageWatermarkOptions()
        options.scale = 50
        aw.lowcode.Watermarker.set_watermark_to_images(input_stream=stream_in, save_options=aw.saving.ImageSaveOptions(aw.SaveFormat.PNG), watermark_image_stream=image_stream, options=options)

See Also