Add arrow annotation in a PDF file using C#

Atir Tahir
2 min readNov 21, 2019

--

We are living in a paper-less era. Everything in business has gone digital. If you are given a document (e.g. PDF, Word, Presentation) and asked to brief the sales achieved in 2018. What will you do? You will try to highlight or add arrow to the concerned text.

Understanding API usage

GroupDocs.Annotation for .NET is a back-end API that can be integrated in any .NET application without any third party/tool dependency. Following are the supported annotation types:

  • Area
  • Arrow
  • Distance
  • Ellipse
  • Link
  • Point

See full list of supported annotations in this article and list of supported file formats here.

Implementation

In this post we will see implementation of arrow annotation in a PDF file. Arrow annotation draws an arrow on the document like shown in the picture below.

annotate PDF in C#

There is an ability to specify the next properties for ArrowAnnotation type:

  • Box — defines annotation position at document page
  • Opacity — allows to set annotation opacity
  • PenColor — defines frame color
  • PenStyle — defines frame line style (solid, dash, dot etc.)
  • PenWidth — defines frame line width in pixels
using (Annotator annotator = new Annotator("input.pdf"))
{
ArrowAnnotation arrow = new ArrowAnnotation
{
Box = new Rectangle(100, 100, 100, 100),
CreatedOn = DateTime.Now,
Message = "This is arrow annotation",
Opacity = 0.7,
PageNumber = 0,
PenColor = 65535,
PenStyle = PenStyle.Dot,
PenWidth = 3,
Replies = new List<Reply>
{
new Reply
{
Comment = "First comment",
RepliedOn = DateTime.Now
},
new Reply
{
Comment = "Second comment",
RepliedOn = DateTime.Now
}
}
};
annotator.Add(arrow);
annotator.Save("result.pdf");
}

Download our open-source example project to evaluate API features. Follow blog to get release and features related updates. If you face any issue, please post it on forum.

--

--

No responses yet