This article walks you through the stepwise process to add watermark annotation to PDF using C#. The annotation library is used to insert annotation into PDF. We will guide you how to configure the annotation package and get you familiar with sample code to create PDF annotation using C#. Following are the complete steps and working code example for inserting formatted watermark into PDF pages and save the final output PDF to disk.
Steps to Add Watermark Annotation to PDF using C#
- Install GroupDocs.Annotation for .NET package from the NuGet to add watermark annotation to PDF
- Add a reference to the GroupDocs.Annotation namespace to create PDF annotation
- Initialize Annotator class and pass path of input PDF file to its constructor
- Initialize WatermarkAnnotation class and set properties for the watermark annotation
- Call the Annotator.Add method and pass the WatermarkAnnotation object to it
- Call Annotator.Save method with the resultant document path to save the output PDF file to disk
We have listed all the essential steps to insert watermark to PDF in C#. You just need to follow these steps to generate PDF with watermark on all pages on any of the common operating systems like Windows, Linux, and macOS that support a .NET environment. Moreover, you do not need to install any additional software for annotation library. Following code example shows how to generate PDF watermark annotation.
Code to Add Watermark Annotation using C#
We have built the above code example to show you the implementation of the C# PDF watermark capability. We have set different properties of WatermarkAnnotation to create annotation in PDF using C#. You can use the properties of this class according to your requirements. This is a step-by-step guide for inserting watermark annotation using C# along with sample code. Recently, we published an article to convert TeX to Word, have a look at how to convert TeX to Word using C# guide for more information.