How to Add PDF Annotation in ASP.NET C#

The samples I find on your GitHub repo are complicated, difficult to understand for newbie.

Is there documentation showing how to setup an ASP.NET project to use GroupDocs.Annotation, add PDF annotation, and setting up license with “Hello World” like example in C#?

Also, can you provide a simple sample project, using a console app project, to do the following:

  • Setup license for GroupDocs.Annotation
  • Execute the following codes:
// C# code
// Create list of annotations
List<AnnotationBase> annotations = new List<AnnotationBase>()
{
    // Instantiate AreaAnnotation with page number, box and message
    new AreaAnnotation()
    {
        PageNumber = 0,
        Box = new Rectangle(100, 100, 100, 100),
        Message = "area"
    },
    // Specify page number, box and message for the Ellipse
    new EllipseAnnotation()
    {
        PageNumber = 0,
        Box = new Rectangle(200, 200, 80, 80),
        Message = "ellipse"
     }
};

// Create annotator
using  (Annotator annotator = new Annotator("C:\output\input.pdf"))
{
    // Pass annotations list to the Add method
    annotator.Add(annotations);
    // Save result to the local storage
    annotator.Save("C:\output\result.pdf", new SaveOptions());
}

Thanks!

1 Like

@samuelphung

Setting up API License in GitHub UI Project

In ASP.NET WebForms application, you can easily set-up license in configuration.yml. You just have to specify the License path. For example:

licensePath: 'D:/Licenses/GroupDocs.Annotation.NET.lic'

Moreover, go through the readme file here.

As far as a simple console application is concerned, please clone/download our open-source GitHub example project. It has both .NET and .NET Core applications.

Create Ellipse Annotation in PDF using C#
There is a separate example/code to add Ellipse in the PDF, you can specify page number to add annotation, background color, pen styles and a lot other properties.

Add Area Annotation to PDF in C#
Area annotation can be added in a PDF document using AreaAnnotation class.

How to Run the Application

Furthermore, we also have a easy-to-understand documentation for you.