using GroupDocs.Annotation;
using GroupDocs.Annotation.Models;
using GroupDocs.Annotation.Models.AnnotationModels;
using System.Collections.Generic;
using System;

namespace AddUnderlineAnnotationintoPDFUsingCSharp
{
    internal class Program
    {
        static void Main(string[] args)
        {
            // Set License to avoid the limitations of Annotation library
            License lic = new License();
            lic.SetLicense(@"GroupDocs.Annotation.lic");

            // Instantiate Annotator object by passing path of PDF
            // file to its constructor
            using (Annotator annotator = new Annotator("input.pdf"))
            {
                // Create an instance of UnderlineAnnotation class
                // and set some properties
                UnderlineAnnotation underline = new UnderlineAnnotation
                {
                    CreatedOn = DateTime.Now,
                    FontColor = 65535,
                    BackgroundColor = 16761035,
                    Message = "This is underline annotation",
                    Opacity = 0.7,
                    PageNumber = 0,
                    UnderlineColor = 1422623, //Supported only Word and PDF documents
                    Points = new List<Point>
                    {
                        new Point(80, 730), new Point(240, 730), 
                        new Point(80, 650), new Point(240, 650)
                    },
                                Replies = new List<Reply>
                    {
                        new Reply
                        {
                            Comment = "First comment",
                            RepliedOn = DateTime.Now
                        },
                        new Reply
                        {
                            Comment = "Second comment",
                            RepliedOn = DateTime.Now
                        }
                    }
                };
                // Add underline annotation to Annotator
                annotator.Add(underline);
                // Save the final PDF to disk
                annotator.Save("result.pdf");
            }
        }
    }
}