Watermarking pages
|
<< Click to Display Table of Contents >> Navigation: Gnostice Document Studio .NET > Going Deeper > Document Viewing > ASP.NET > Watermarking pages |
Documents go through many stages of completion before being finalized or they may be categorized based on the level of secrecy of the information contained in them. It often helps to convey this meta information to the stakeholders so they are aware of the document status when working with it. One of the ways to do this is by showing a watermark on each page of the document. Also, the watermarking may only be required to be shown when viewing and printing the document and not be applied on the document itself. The ASP.NET document viewer allows view and print pages to be watermarked. In this section we cover how this can be done.
Adding watermark is achieved by handling the afterPageDraw event in the JavaScript code. The event passes many parameters one of which is the 2D graphics context of the HTML canvas on which the document page is already drawn. The watermark text needs to be drawn using this graphics context.
After creating the document viewer object add the event handler which draws the text.
$(document).ready(function () { |
You can see the screen-shot below which shows the viewer displaying the document with the added watermark.

The watermark is also visible in the printed pages.

However the document itself is unchanged so a downloaded copy of it will NOT contain the watermark.
For reference here are the properties passed in the event data object of the "afterPageDraw" event:
{ |