Free Support Forum -

Restrict Watermark Replication

Hi Usman,

I’m using groupdcos version 17.2.0. I want to restrict watermark only to the first page of the document unlike on every page. Do we have any provision for the same?

Hi Shinde,

Thanks for using GroupDocs.Viewer for .NET.

Currently, there is no builtin method to achieve this functionality. However, you can render the document in 2 phases and then concatenate all the pages. The following code sample may help you in this case:

HtmlOptions options = new HtmlOptions();
options.IsResourcesEmbedded = true;

Watermark watermark = new Watermark(“This is watermark text”);
watermark.Color = System.Drawing.Color.Blue;
watermark.Position = WatermarkPosition.Diagonal;
watermark.Width = 100;

options.Watermark = watermark;
options.PageNumber = 1;
options.CountPagesToRender = 1;
// Get document first with watermark
List FirstPage = htmlHandler.GetPages(guid, options);

// Settings for remaining pages
options.PageNumber = 2;
options.CountPagesToRender = htmlHandler.GetDocumentInfo(guid).Pages.Count;
options.Watermark = null;

List RemainingPages = htmlHandler.GetPages(guid, options);

// Merge all the pages in one list
List AllPages = FirstPage.Union(RemainingPages).ToList();

Hope it helps.

Warm Regards

Hi Usman,

It worked perfectly. Thanks a lot.

Hi Shinde,

You are always welcome.

Warm Regards