Class ImageWatermarkOptions

Class ImageWatermarkOptions

Namespace: Aspose.Words
Assembly: Aspose.Words.dll (25.12.0)

Contains options that can be specified when adding a watermark with image.

To learn more, visit the Working with Watermark documentation article.

public class ImageWatermarkOptions

Inheritance

object ImageWatermarkOptions

Inherited Members

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

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 || CPLUSPLUS
                                                                                              // We have a different options to insert image.
                                                                                              // Use on of the following methods to add image watermark.
                                                                                              doc.Watermark.SetImage(Image.FromFile(ImageDir + "Logo.jpg"));

                                                                                              doc.Watermark.SetImage(Image.FromFile(ImageDir + "Logo.jpg"), imageWatermarkOptions);

                                                                                              doc.Watermark.SetImage(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");

Constructors

ImageWatermarkOptions()

public ImageWatermarkOptions()

Properties

IsWashout

Gets or sets a boolean value which is responsible for washout effect of the watermark. The default value is true.

public bool IsWashout { get; set; }

Property Value

bool

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 || CPLUSPLUS
                                                                                              // We have a different options to insert image.
                                                                                              // Use on of the following methods to add image watermark.
                                                                                              doc.Watermark.SetImage(Image.FromFile(ImageDir + "Logo.jpg"));

                                                                                              doc.Watermark.SetImage(Image.FromFile(ImageDir + "Logo.jpg"), imageWatermarkOptions);

                                                                                              doc.Watermark.SetImage(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");

Scale

Gets or sets the scale factor expressed as a fraction of the image. The default value is 0 - auto.

public double Scale { get; set; }

Property Value

double

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 || CPLUSPLUS
                                                                                              // We have a different options to insert image.
                                                                                              // Use on of the following methods to add image watermark.
                                                                                              doc.Watermark.SetImage(Image.FromFile(ImageDir + "Logo.jpg"));

                                                                                              doc.Watermark.SetImage(Image.FromFile(ImageDir + "Logo.jpg"), imageWatermarkOptions);

                                                                                              doc.Watermark.SetImage(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");

Remarks

Valid values range from 0 to 65.5 inclusive.

Auto scale means that the watermark will be scaled to its max width and max height relative to the page margins.

Exceptions

ArgumentOutOfRangeException

Throws when argument was out of the range of valid values.

 English