Add text watermarks

To add a watermark to the HTML/JPG/PNG/PDF output, follow these steps:

  1. Create an instance of the HtmlViewOptions class (or PngViewOptions, or JpgViewOption, or PdfViewOptions);
  2. Create a Watermark object and populate its properties;
  3. Assign the Watermark object to HtmlViewOptions.Watermark (or PngViewOptions.Watermark, or JpgViewOptions.Watermark, or PdfViewOptions.Watermark) property;
  4. Call the View method.

The following code snippet shows how to apply the watermark to the output pages.

using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...

using (Viewer viewer = new Viewer("sample.docx"))
{
    // Create an HTML file.
    HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources();
    // Add watermark
    viewOptions.Watermark = new Watermark("This is a watermark");
    viewer.View(viewOptions);
}
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...

Module Program
    Sub Main(args As String())
        Using viewer As Viewer = New Viewer("sample.docx")
            ' Create an HTML file.
            Dim viewOptions As HtmlViewOptions = HtmlViewOptions.ForEmbeddedResources   ()
            ' Add watermark
            viewOptions.Watermark = New Watermark("This is a watermark")
            viewer.View(viewOptions)
        End Using
    End Sub
End Module