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.
Before getting started, please check the following information to successfully set up the ultimate document annotation APIs for .NET or Java platform.
Let’s take a look at some use cases designed to make the document and image annotation process convenient and easy for you.
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.
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"); }
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"); }
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.Listreplies = 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(); } }
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.Listreplies = 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.
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.
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"); }
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.Listreplies = 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(); } }
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.
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"); }
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"); }
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.Listreplies = 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(); } }
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.Listreplies = 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(); } }
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.
using (Annotator annotator = new Annotator("annotated.pdf")) { Listannotations = annotator.Get(); XmlSerializer formatter = new XmlSerializer(typeof(List )); using (FileStream fs = new FileStream("annotations.xml", FileMode.Create)) { fs.SetLength(0); formatter.Serialize(fs, annotations); } }
LoadOptions tmp0 = new LoadOptions(); // Create an instance of Annotator class Annotator annotator = new Annotator("InputPath", tmp0); // Get all annotations Listannotations = annotator.get();
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.