A smarter way to develop powerful Microsoft Office and PDF annotator apps

Annotation APIs for developers to create and manage link, underline, polyline, watermark, and text annotations in PDF, Word, Excel, PowerPoint, Visio, Images, HTML, and Email files.

Try our APIs for FreeGet Temporary License

Leverage the power of document annotator libraries to drive your business forward

Annotations are a great way of making notes on documents, images, or other file types. They can be best used to highlight or explain particular points, provide feedback, or share information within a data file. Annotations could also be created with special kinds of markup tools to strike through, underline or highlight text or images in a document. There are many different types of annotations that developers can use for different purposes such as rectangular area, polyline, arrow, ellipse, link, watermark, and text annotation. If you are looking to automate your document and image annotation processes, you can use GroupDocs.Annotation APIs for .NET and Java platforms. These powerful libraries are built to work with PDF, Microsoft Office (Word, Excel, PowerPoint, Visio), OpenDocument, CAD Drawings, and images, as well as HTML and Email files enabling .NET and Java app developers to add annotations to a document in an easy way. The APIs are designed for use in C#, ASP.NET, VB.NET, and Java languages, across multiple frameworks and environments.

Getting Started

Before getting started, please check the .NET and Java installation guides of GroupDocs.Annotation APIs to help you correctly set up the development environment.

Document annotation use cases

Let’s take a look at some use cases designed to make the document annotating process convenient and easy for you.

How to add annotations to your documents and images?

As an application developer, you are always looking for ways to simplify the app-building process and save on turn-around time. This is where GroupDocs.Annotation APIs bring unmatched prowess and provide you with the right platform. Using these lightweight, cross-platform libraries, .NET and Java developers can build feature-rich and smarter solutions for adding annotations to PDF, and Word documents, Excel, and PowerPoint documents as well as VSD, DWG, PNG, and JPEG files.

How to add annotations to your documents and images?

PDF reader in C# .NET

From area, polyline, image, and watermark to link, point, ellipse, and text annotations, you can pick and choose what kind of annotations you wish to inject into your personal or work documents in .NET. For instance, the following code will add an annotation in form of a rectangular area:
using (Annotator annotator = new Annotator("input.pdf"))
{
	AreaAnnotation area = new AreaAnnotation
    {
        BackgroundColor = 65535,
        Box = new Rectangle(100, 100, 100, 100),
        CreatedOn = DateTime.Now,
        Message = "This is area annotation",
        Opacity = 0.7,
        PageNumber = 0,
        PenColor = 65535,
        PenStyle = PenStyle.Dot,
        PenWidth = 3,
        Replies = new List
        {
        	new Reply
            {
            	Comment = "First comment",
                RepliedOn = DateTime.Now
            },
            new Reply
            {
            	Comment = "Second comment",
                RepliedOn = DateTime.Now
            }
        }
    };
    annotator.Add(area);
    annotator.Save("result.pdf");
}
    
Similarly, the following code helps you add an image annotation to your .NET documents:
using (Annotator annotator = new Annotator("input.pdf"))
            {
                ImageAnnotation area = new ImageAnnotation
                {
                    Box = new Rectangle(100, 100, 100, 100),
                    Opacity = 0.7,
                    PageNumber = 0,
                    ImagePath = "www.google.com.ua/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png",
                    Angle = 100
                };
                annotator.Add(area);
                annotator.Save("result.pdf");
            }

    
Therefore, you can keep adding different types of available annotations seamlessly.

Annotating files in Java

Annotating your files in Java is no different, you can access and use all aforementioned annotations in the Java platform too. Please use the following code to insert a text annotation to your document:
Annotator annotator = new Annotator("inputPath");
try {
    // Create an instance of Reply class and add comments
    Reply reply1 = new Reply();
    reply1.setComment("First comment");
    reply1.setRepliedOn(Calendar.getInstance().getTime());

    Reply reply2 = new Reply();
    reply2.setComment("Second comment");
    reply2.setRepliedOn(Calendar.getInstance().getTime());

    java.util.List replies =  new ArrayList();
    replies.add(reply1);
    replies.add(reply2);

    // Create an instance of TextFieldAnnotation class and set options
    TextFieldAnnotation textField = new TextFieldAnnotation();
    textField.setBackgroundColor(65535);
    textField.setBox(new Rectangle(100, 100, 100, 100));
    textField.setCreatedOn(Calendar.getInstance().getTime());
    textField.setText("Some text");
    textField.setFontColor(65535);
    textField.setFontSize((double)12);
    textField.setMessage("This is text field annotation");
    textField.setOpacity(0.7);
    textField.setPageNumber(0);
    textField.setPenStyle(PenStyle.Dot);
    textField.setPenWidth((byte) 3);
    textField.setReplies(replies);
    
    // Add annotation and save to file
    annotator.add(textField);
    annotator.save("outputPath");
} finally {
    if (annotator != null) {
        annotator.dispose();
    }
}
    
To add a link annotation in Java, please use the below-given code:
Annotator annotator = new Annotator("inputPath");
try {
    // Create an instance of Reply class and add comments
    Reply reply1 = new Reply();
    reply1.setComment("First comment");
    reply1.setRepliedOn(Calendar.getInstance().getTime());

    Reply reply2 = new Reply();
    reply2.setComment("Second comment");
    reply2.setRepliedOn(Calendar.getInstance().getTime());

    java.util.List replies = Arrays.asList(reply1, reply2);
    
    List points = Arrays.asList(new Point(80, 730), new Point(240, 730), new Point(80, 650), new Point(240, 650));                
    
    // Create an instance of LinkAnnotation class and set options
    LinkAnnotation link = new LinkAnnotation();
    link.setCreatedOn(Calendar.getInstance().getTime());
    link.setMessage("This is link annotation");
    link.setOpacity(0.7);
    link.setPageNumber(0);
    
    link.setPoints(points);               
    
    link.setReplies(replies);
    link.setUrl("https://www.google.com");
    
    // Add annotation and save to file
    annotator.add(link);
    annotator.save("outputPath");
} finally {
    if (annotator != null) {
        annotator.dispose();
    }
}

    

Learn to add watermark annotations to different data files

Text-based watermarks are commonly used in official and personal files as a copyright or trademark symbol, expiration date, or some other form of text that needs to be displayed in the document. GroupDocs.Annotation APIs allow you to add watermark annotations to different data files both in .NET and Java.

Learn to add watermark annotations to different data files

Text watermark PDF annotator in .NET

You can update files with a watermark annotation within your .NET apps. Please use the following code for achieving this:
using (Annotator annotator = new Annotator("input.pdf"))
{
	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
        {
        	new Reply
            {
            	Comment = "First comment",
                RepliedOn = DateTime.Now
            },
            new Reply
            {
            	Comment = "Second comment",
                RepliedOn = DateTime.Now
            }
        }
    };
    annotator.Add(watermark);
    annotator.Save("result.pdf");
}
    

Adding watermark text annotations in Java

To use this feature in Java, please use the following piece of code:
Annotator annotator = new Annotator("inputPath");
try {
    // Create an instance of Reply class and add comments
    Reply reply1 = new Reply();
    reply1.setComment("First comment");
    reply1.setRepliedOn(Calendar.getInstance().getTime());

    Reply reply2 = new Reply();
    reply2.setComment("Second comment");
    reply2.setRepliedOn(Calendar.getInstance().getTime());

    java.util.List replies =  new ArrayList();
    replies.add(reply1);
    replies.add(reply2);

    // Create an instance of WatermarkAnnotation class and set options
    WatermarkAnnotation watermark = new WatermarkAnnotation();
    watermark.setAngle((double) 75);
    watermark.setBox(new Rectangle(200, 200, 100, 50));
    watermark.setCreatedOn(Calendar.getInstance().getTime());
    watermark.setText("Watermark");
    watermark.setFontColor(65535);
    watermark.setFontSize((double) 12);
    watermark.setMessage("This is watermark annotation");
    watermark.setOpacity(0.7);
    watermark.setPageNumber(0);
    watermark.setReplies(replies);
    
    // Add annotation and save to file
    annotator.add(watermark);
    annotator.save("outputPath");
} finally {
    if (annotator != null) {
        annotator.dispose();
    }
}

    

Insert underline and strike-through markups to file contents

To differentiate certain parts of text from other contents within a document, you will need to apply text markup decorations by underlining or striking out the text. Such markup features have been integrated into our APIs in form of underline and strikethrough annotations which you can use in your documents and images.

Insert underline and strike-through markups to file contents

Text markup annotations in .NET

Apply squiggly underline markup annotation to your .NET documents with the help of the following code:
    using (Annotator annotator = new Annotator("input.pdf"))
    {
        SquigglyAnnotation squiggly = new SquigglyAnnotation
        {
            CreatedOn = DateTime.Now,
            FontColor = 65535,
            BackgroundColor = 16761035,
            Message = "This is squiggly annotation",
            Opacity = 0.7,
            PageNumber = 0,
            SquigglyColor = 1422623, //Supported only Word and PDF
            Points = new List
            {
                new Point(80, 730), new Point(240, 730), new Point(80, 650), new Point(240, 650)
            },
            Replies = new List
            {
                new Reply
                {
                    Comment = "First comment",
                    RepliedOn = DateTime.Now
                },
                new Reply
                {
                    Comment = "Second comment",
                    RepliedOn = DateTime.Now
                }
            }
        };
        annotator.Add(squiggly);
        annotator.Save("result.pdf");
    }    
        
This code lets you add strikethrough annotations to files in your C# .NET apps:
        using (Annotator annotator = new Annotator("input.pdf"))
{
	StrikeoutAnnotation strikeout = new StrikeoutAnnotation
    {
    	CreatedOn = DateTime.Now,
        FontColor = 65535,
        BackgroundColor = 16761035,
        Message = "This is strikeout annotation",
        Opacity = 0.7,
        PageNumber = 0,
        Points = new List
        {
        	new Point(80, 730), new Point(240, 730), new Point(80, 650), new Point(240, 650)
        },
        Replies = new List
        {
        	new Reply
            {
             	Comment = "First comment",
                RepliedOn = DateTime.Now
            },
            new Reply
            {
            	Comment = "Second comment",
                RepliedOn = DateTime.Now
            }
        }
     };
     annotator.Add(strikeout);
     annotator.Save("result.pdf");
}
        

Markup annotations in Java

Along with .NET, markup annotations are also available in the Java platform. Please utilize the code shown below to add highlight annotations to your files:
    Annotator annotator = new Annotator("inputPath");
    try {
        // Create an instance of Reply class and add comments
        Reply reply1 = new Reply();
        reply1.setComment("First comment");
        reply1.setRepliedOn(Calendar.getInstance().getTime());
    
        Reply reply2 = new Reply();
        reply2.setComment("Second comment");
        reply2.setRepliedOn(Calendar.getInstance().getTime());
    
        java.util.List replies =  new ArrayList();
        replies.add(reply1);
        replies.add(reply2);
    
        Point point1 = new Point(80, 730);
        Point point2 = new Point(240, 730);
        Point point3 = new Point(80, 650);
        Point point4 = new Point(240, 650);
    
        List points = new ArrayList();
        points.add(point1);
        points.add(point2);
        points.add(point3);
        points.add(point4);
    
        // Create an instance of HighlightAnnotation class and set options
        HighlightAnnotation highlight = new HighlightAnnotation();
        highlight.setBackgroundColor(65535);
        highlight.setCreatedOn(Calendar.getInstance().getTime());
        highlight.setFontColor(0);
        highlight.setMessage("This is highlight annotation");
        highlight.setOpacity(0.5);
        highlight.setPageNumber(0);
        highlight.setPoints(points);
        highlight.setReplies(replies);
        
        // Add annotation and save to file
        annotator.add(highlight);
        annotator.save("outputPath");
    } finally {
        if (annotator != null) {
            annotator.dispose();
        }
    }    
        
Another popular form of markup annotation is the underline annotation which could be added to your Java data file formats using this code:
        Annotator annotator = new Annotator("inputPath");
try {
    // Create an instance of Reply class and add comments
    Reply reply1 = new Reply();
    reply1.setComment("First comment");
    reply1.setRepliedOn(Calendar.getInstance().getTime());

    Reply reply2 = new Reply();
    reply2.setComment("Second comment");
    reply2.setRepliedOn(Calendar.getInstance().getTime());

    java.util.List replies =  new ArrayList();
    replies.add(reply1);
    replies.add(reply2);

    Point point1 = new Point(80, 730);
    Point point2 = new Point(240, 730);
    Point point3 = new Point(80, 650);
    Point point4 = new Point(240, 650);

    List points = new ArrayList();
    points.add(point1);
    points.add(point2);
    points.add(point3);
    points.add(point4);

    // Create an instance of AreaAnnotation class and set options
    UnderlineAnnotation underline = new UnderlineAnnotation();
    underline.setCreatedOn(Calendar.getInstance().getTime());
    underline.setFontColor(65535);
    underline.setMessage("This is underline annotation");
    underline.setOpacity(0.1);
    underline.setPageNumber(0);
    underline.setPoints(points);
    underline.setReplies(replies);
    
    // Add annotation and save to file
    annotator.add(underline);
    annotator.save("outputPath");
} finally {
    if (annotator != null) {
        annotator.dispose();
    }
}
        

An easier way to extract or remove annotations

You can not only add new annotations but also extract the existing annotations from your files and remove the added annotations before exporting the document to its pre-annotation state across your C#, ASP.NET, VB.NET, and Java applications.

An easier way to extract or remove annotations

Annotation extraction and removal in .NET

Leverage these important API features in .NET environment easily. To extract the annotations already added to the document, please make use of the following code:
    using (Annotator annotator = new Annotator("annotated.pdf"))
{
	List annotations = annotator.Get();
    XmlSerializer formatter = new XmlSerializer(typeof(List));
    using (FileStream fs = new FileStream("annotations.xml", FileMode.Create))
    {
    	fs.SetLength(0);
        formatter.Serialize(fs, annotations);
    }
}
        
And to remove the annotations from a file using the list of annotations and then saving the updated file to its prior state, please try this code:
        using (Annotator annotator = new Annotator("result.xlsx"))
        {
            var tmp = annotator.Get();
            annotator.Remove(tmp);
            annotator.Save("removed.xlsx");
        }        
        

Extract annotations or remove them in Java

It would take only a few lines of code to extract annotations from documents or remove them in Java. To extract the document annotations, you can use this code:
    LoadOptions tmp0 = new LoadOptions();
    // Create an instance of Annotator class
    Annotator annotator = new Annotator("InputPath", tmp0);
    // Get all annotations
    List annotations = annotator.get();    
        
Similarly, please use the code given below to remove annotations and export the updated file:
        // Create an instance of Annotator class
Annotator annotator = new Annotator("inputPath");
SaveOptions saveOptions = new SaveOptions();
saveOptions.setAnnotationTypes(AnnotationType.None);
// Save result to file
annotator.save("outputPath", saveOptions);
        
You can also utilize our free online annotation apps to quickly add multiple types of annotations to your PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, VSD, PNG, JPEG, EML, and HTML files.

Independently automate your document and image processing tasks

Why choose GroupDocs?

Unmatched file formats support

  • All popular file formats supported including documents, images, audio, videos, and ebooks.
  • PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, PUB, PNG, PSD, ODT, MSG, EML, MP3, MP4, and many more.

Extensively programmable libraries

  • Use GroupDocs APIs to build fully customizable .NET and Java apps.
  • Manipulate your business documents, spreadsheets, presentations, and images any way you like.

Hundreds of supported features

  • Convert Word or Excel to PDF, annotate PDFs, edit DOC, DOCX, or watermark files.
  • Work with esignatures, tables, mail-merge, attachments, shapes, and much more.

Tailored to your needs

  • Free trials and different paid licensing options to choose from.
  • Well-suited to individual users, startups, as well as small and large enterprises.

APIs for Developers

  • Programmatically process your digital documents and images in .NET and Java platforms.
  • Document APIs designed specifically for .NET and Java application developers.

Trusted by users globally

  • Preferred by developers and businesses alike, our libraries are used globally.
  • Generate optimised documents easily in standalone and distributed environments.

Do more with your documents and images

  • Create, render, edit, convert, compare, digitally sign, watermark, and export your files.
  • Experience endless possibilities by creating multi-functional, high-performance apps.

Simple integration and convenient application

  • Enjoy greater flexibility by integrating with your existing software applications.
  • Get up and running using a few lines of code with our super-fast and reliable APIs.

Multiple support channels

  • Need help? Look no further than one of our developer-led support options.
  • Explore the APIs structure, and documentation, or dive into the knowledge base.

Ready to get started?

Download Free Trial