Apply Watermark To The Converted Document Using C#

In this blog post, we'll develop a document conversion application. And the scope is not just limited to converting a Word to PDF. We will see how we could add a (non-removeable) patent or watermark in the resultant PDF.

Watermark Options

It's not just like adding a simple background watermark. You can control or set the following options/properties while adding a watermark:
  • Background - Stamp watermark as background, if we set it to true, watermark will be laid at bottom otherwise on top
  • Color - Set watermark color
  • Font - e.g Comis Sans, Times New Roman
  • Height/Width
  • Rotation angle
  • Transparency

Setting Image Watermark

 API also allows you to set image watermark. It has a property Image, you have to set it to image byte array.
Let's convert a Word file to PDF and add some watermar with the options/properties specified earlier. 
  1. using (var converter = new Converter(@"D:/sample.docx"))  
  2. {  
  3.       PdfConvertOptions convert = new PdfConvertOptions();  
  4.       WatermarkOptions options = new WatermarkOptions();  
  5.       options.Text = "Sample Watermark";  
  6.       options.Color = Color.Red;  
  7.       options.Transparency = 0.8;  
  8.       options.Top = 190;  
  9.       options.Left = 50;  
  10.       options.Background = true;  
  11.       options.RotationAngle = 90;  
  12.       convert.Watermark = options;  
  13.       converter.Convert(@"D:/output.pdf", convert);  
  14. }  
Have a look at the Word source file (image below),
Apply Watermark To The Converted Document Using C#
And the following PDF output:
Apply Watermark To The Converted Document Using C#


You can see how we controlled watermark positioning, color, rotation etc. Eventually, you have a PDF with a non-removable patent. All you have to do is to add this DLL reference in your .NET project. You don't have to install or refer to any third party tool or software. For further details or in case of any issue, you can post here.