How to Add Watermark Annotation to PDF using C#. For more information, please follow link: https://kb.groupdocs.com/annotation/net/how-to-add-watermark-annotation-to-pdf-using-csharp/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using GroupDocs.Annotation; | |
using GroupDocs.Annotation.Models; | |
using GroupDocs.Annotation.Models.AnnotationModels; | |
namespace AddWatermarkAnnotationtoPDFUsingCSharp | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//Set License to avoid the limitations of Annotation library | |
License lic = new License(); | |
lic.SetLicense(@"Conholdate.Annotator.lic"); | |
//Instantiate Annotator object with input PDF path | |
using (Annotator annotator = new Annotator("input.pdf")) | |
{ | |
//Instantiate WatermarkAnnotation object and set it's properties | |
WatermarkAnnotation watermark = new WatermarkAnnotation | |
{ | |
Angle = 75, | |
Box = new Rectangle(200, 200, 100, 50), | |
CreatedOn = DateTime.Now, | |
Text = "Watermark", | |
FontColor = 65535, | |
FontSize = 12, | |
Message = "This is watermark annotation", | |
Opacity = 0.7, | |
AutoScale = true, | |
HorizontalAlignment = HorizontalAlignment.Center, | |
VerticalAlignment = VerticalAlignment.Center, | |
Replies = new List<Reply> | |
{ | |
new Reply | |
{ | |
Comment = "First comment", | |
RepliedOn = DateTime.Now | |
}, | |
new Reply | |
{ | |
Comment = "Second comment", | |
RepliedOn = DateTime.Now | |
} | |
} | |
}; | |
//Add Watermark Annotation to PDF | |
annotator.Add(watermark); | |
//Save the final output PDF | |
annotator.Save("result.pdf"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment