Add text watermarks

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Viewer MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-viewer -- dnx GroupDocs.Viewer.Mcp --yes
Folders, licensing and more →

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

sample.docx is the sample file used in this example. Click here to download it.

p_1.html (229 KB)
p_2.html (111 KB)
p_3.html (143 KB)
p_4.html (886 KB)
p_5.html (88 KB)

Download full output