English

Efficient Document Annotation APIs for PDF, Office & More Files

GroupDocs provides powerful document annotation APIs for developers to effortlessly add and manage text, watermark, link, underline, and polyline annotations to PDF, Word, Excel, PowerPoint, Images, Emails, and HTML files.

View all APIsTry our APIs for Free

Drive Your Business Forward with Document Annotation APIs

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 efficient document annotation APIs 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 following information to successfully set up the ultimate document annotation APIs for .NET or Java platform.

GroupDocs.Annotation for .NET installation

Please download the MSI installer or the DLLs directly from the downloads section. Or, you may use the NuGet package for the API installation. The Package Manager command is shared below :
PM > Install-Package GroupDocs.Annotation 

GroupDocs.Annotation for Java installation

Please download the JAR files of the Java document annotation library from the downloads section. Or, get the latest repository and dependency configurations for your Maven-based Java apps.
<repository>
	<id>GroupDocsJavaAPI</id>
	<name>GroupDocs Java API</name>
	<url>http://repository.groupdocs.com/repo/</url>
</repository>
<dependency>
        <groupId>com.groupdocs</groupId>
        <artifactId>groupdocs-annotation</artifactId>
        <version>21.7.2</version> 
</dependency>
   

Document Annotation Use Cases

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

Adding Annotations of Different Types to 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 APIs for document markup, .NET and Java developers can build feature-rich and smarter solutions to add annotations to PDF and Word documents, Excel, PowerPoint, VSD, DWG, PNG, and JPEG files.

Adding Annotations of Different Types to Documents and Images

Document Annotation API for .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 the 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");
            }

    

Java document annotation library

Annotating your files in Java is no different, you can access and use all annotation types for documents that are supported in the .NET version for the Java platform too. Please use the following example code to annotate Word documents programmatically using a text annotation:
Annotator annotator = new Annotator("input.docx");
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 to your documents 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();
    }
}

    

You can add and manage annotations for all supported file formats. Developers can efficiently build fully customizable, cross-platform, automated document annotation solutions in .NET and Java to take their document processing apps to the next level.

Add Watermark Annotations to PDF, Word, Excel, and More 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 enable you to add annotations to documents in the form of watermarks both in .NET and Java platforms by developing document and PDF annotation apps.

Add Watermark Annotations to PDF, Word, Excel, and More Files

.NET PDF Annotation API for Developers

You can build document review and markup solutions to annotate PDFs and other documents with watermark annotations in .NET using the following code:
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");
}
    

Manage annotations in documents in Java

You can upgrade your secure document annotation solutions or PDF annotation apps in the Java platform too using the following sample 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();
    }
}

    

Underline and Strike-through Markups: Organize and Highlight Content

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 document and image annotation APIs for .NET and Java in the form of underline and strikethrough annotations which you can use in your documents and images. Effortlessly perform cross-platform document annotation and develop solutions to annotate PDFs, add annotations to Word documents, annotate Excel spreadsheets or PowerPoint presentations, and other supported files.

Underline and Strike-through Markups: Organize and Highlight Content

Document Markup Solutions 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");
}
        

Build Document Markup Tools in Java

To add highlight annotation to your Java documents for highlighting specific text, please use the following sample 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 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 markup annotation that you can add to your Java files using the following code is the underline annotation:
        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();
    }
}
        

Managing Annotations: Extract or Remove Annotations Easily

You can not only add and manage 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 using the document and image annotation APIs.

Managing Annotations: Extract or Remove Annotations Easily

Extract and Remove Annotations 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 document annotations or remove them in Java. To extract 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 document annotation apps to quickly add multiple types of annotations to 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