Add Watermark

Wordize Watermark for .NET allows you to add a watermark to your document. The watermark can be text or an image.
Supported Modules and Document Formats

Wordize supports adding watermarks to documents of any format:

  • to add a watermark, use the Wordize Comparison for .NET module
  • to work with documents in the required formats, select the appropriate document conversion module

Wordize provides the Wordize Watermark module for .NET, which offers robust functionality for adding watermarks to your documents, enhancing security and branding. You can insert both text and image watermarks with customizable options to suit your requirements.

Watermark Types

A watermark is inserted behind the main document content. You can add an image or text watermark:

  • Image watermark: inserts images, such as logos or seals, as watermarks
  • Text watermark: inserts text such as “Confidential” or “Draft” as a watermark
Important to note:
If the input document is PDF and the output document has a fixed page format (where the geometry of objects and their position on the page are fixed, such as PDF or image formats), for better performance and fidelity, adding watermark is performed without reading PDF documents into the internal flow Document Object Model.

Adding an Image Watermark

Wordize allows you to add an image watermark to your document. The functionality of adding an image watermark in Wordize is available through the Watermarker class, which provides SetImage methods.

Add image watermark

The following code example shows how to add an image watermark to a document:

var doc = "Document.docx";
string watermarkImage = "Logo.jpg";

Watermarker.SetImage(doc, "WatermarkImage.1.docx", watermarkImage);

Wordize also allows you to customize the image watermark using ImageWatermarkOptions:

  • Scale – to specify the scale factor expressed as a fraction of the image, the default value is 0 - auto, valid values range from 0 to 65.5 inclusive
  • IsWashout – specifies a boolean value that is responsible for the washout effect of the watermark, the default value is “true”

The following code example shows how to set up a text watermark using Scale:

var doc = "Document.docx";
string watermarkImage = "Logo.jpg";

ImageWatermarkOptions options = new ImageWatermarkOptions();
options.Scale = 50;

Watermarker.SetImage(doc, "WatermarkImage.3.docx", watermarkImage, options);

Adding a Text Watermark

Wordize also allows you to add a text watermark to your document. The functionality of adding a text watermark in Wordize is available through the Watermarker class, which provides SetText methods.

Add text watermark

The following code example shows how to add a text watermark to a document:

var doc = "Document.docx";
string watermarkText = "This is a watermark";

Watermarker.SetText(doc, "WatermarkText.1.docx", watermarkText);

You can customize the text watermark using TextWatermarkOptions:

  • FontFamily – to specify the font family name, the default value is “Calibri”
  • Color – to specify the font color, the default value is “Silver”
  • FontSize – to specify the font size, the default value is 0 – “auto”
  • IsSemitrasparent – to specify a boolean value that controls the watermark opacity, the default value is “true”
  • Layout – to specify the watermark layout, the default value is “Diagonal”

The following code example shows how to customize a text watermark using Color:

var doc = "Document.docx";
string watermarkText = "This is a watermark";

TextWatermarkOptions watermarkOptions = new TextWatermarkOptions();
watermarkOptions.Color = Color.Red;

Watermarker.SetText(doc, "WatermarkText.3.docx", watermarkText, watermarkOptions);

Save Watermarked Document as an Image

You can add text ar image watermark to a document and save the result as an image using the SetWatermarkToImages method. In this case, each element of the returned array represents one page of output, rendered as an image.

The following code examples show how to save a document with image watermark in PNG:

Stream[] pages = Watermarker.SetWatermarkToImages("Document.docx", new Saving.ImageSaveOptions(SaveFormat.Png), File.ReadAllBytes("watermark.png"));
using var streamIn = File.OpenRead("Document.docx");
using var watermarkStream = File.Create("watermark.png");

Stream[] pages = Watermarker.SetWatermarkToImages(streamIn, new Saving.ImageSaveOptions(SaveFormat.Png), watermarkStream);

The following code examples show how to save a document with text watermark in PNG:

Stream[] pages = Watermarker.SetWatermarkToImages("Document.docx", new Saving.ImageSaveOptions(SaveFormat.Png), "This is a watermark");
using var streamIn = File.OpenRead("Document.docx");

Stream[] pages = Watermarker.SetWatermarkToImages(streamIn, new Saving.ImageSaveOptions(SaveFormat.Png), "This is a watermark");

See Also