SetImage

SetImage(Image)

Adds Image watermark into the document.

public void SetImage(Image image)
ParameterTypeDescription
imageImageImage that is displayed as a watermark.

Exceptions

exceptioncondition
ArgumentNullExceptionThrows when the image is null.

See Also


SetImage(Image, ImageWatermarkOptions)

Adds Image watermark into the document.

public void SetImage(Image image, ImageWatermarkOptions options)
ParameterTypeDescription
imageImageImage that is displayed as a watermark.
optionsImageWatermarkOptionsDefines additional options for the image watermark.

Exceptions

exceptioncondition
ArgumentNullExceptionThrows when the image is null.

Remarks

If ImageWatermarkOptions is null, the watermark will be set with default options.

Examples

Shows how to create a watermark from an image in the local file system.

Document doc = new Document();

            // Modify the image watermark's appearance with an ImageWatermarkOptions object,
            // then pass it while creating a watermark from an image file.
            ImageWatermarkOptions imageWatermarkOptions = new ImageWatermarkOptions();
            imageWatermarkOptions.Scale = 5;
            imageWatermarkOptions.IsWashout = false;

#if NET461_OR_GREATER || JAVA
            doc.Watermark.SetImage(Image.FromFile(ImageDir + "Logo.jpg"), imageWatermarkOptions);
#elif NET5_0_OR_GREATER
            using (SKBitmap image = SKBitmap.Decode(ImageDir + "Logo.jpg"))
            {
                doc.Watermark.SetImage(image, imageWatermarkOptions);
            }
#endif

            doc.Save(ArtifactsDir + "Document.ImageWatermark.docx");

See Also


SetImage(string, ImageWatermarkOptions)

Adds Image watermark into the document.

public void SetImage(string imagePath, ImageWatermarkOptions options)
ParameterTypeDescription
imagePathStringPath to the image file that is displayed as a watermark.
optionsImageWatermarkOptionsDefines additional options for the image watermark.

Exceptions

exceptioncondition
ArgumentNullExceptionThrows when the path is null.

Remarks

If ImageWatermarkOptions is null, the watermark will be set with default options.

See Also