PDF Annotator lets the user open any PDF file and add annotations as notes, comments, highlights, links in C# Class.

PDFs are great, portable, cross-platform documents that you can read on your Mac, your iPad or iPhone, or on a PC. But this ubiquitous file format is also useful when you need to share works in progress with your colleagues. So the annotation in PDF is important, it can make a short comment on a long document, can fill in or sign a form or agreement, and return it by email, can Illustrate your ideas and suggestions, and so on.

XsPDF annotator lets you easily add notes and comments to PDFs. Three types of PDF annottions are supported now: text annotation, link annotation and rubber stamp annotation.

In this C# .NET guide, we will show you how to insert and render three types of annotations mentioned above to PDF in simple style and step.

// Create a new PDF document.
PdfDocument document = new PdfDocument();

// Create a page.
PdfPage page = document.AddPage();

// Get current page graphics
XGraphics g = XGraphics.FromPdfPage(page);
// Create a PDF text annotation.
PdfTextAnnotation textAnnot = new PdfTextAnnotation();
textAnnot.Title = "Title sample";
textAnnot.Subject = "Subject sample";
textAnnot.Contents = "This is the first line of annotation.\rThis is the 2nd line.";
textAnnot.Icon = PdfTextAnnotationIcon.Comment;

// Convert rectangle from world space to page space(visual to graphics drawing). It's necessary because
// the annotation is placed relative to the bottom left corner of the page with units measured in point.
XRect rect = g.Transformer.WorldToDefaultPage(new XRect(new XPoint(100, 60), new XSize(50, 50)));
textAnnot.Rectangle = new PdfRectangle(rect);

// Add the annotation to the page

// Create a PDF rubber stamp annotation.
PdfRubberStampAnnotation rsAnnot = new PdfRubberStampAnnotation();
rsAnnot.Icon = PdfRubberStampAnnotationIcon.Approved;

rect = g.Transformer.WorldToDefaultPage(new XRect(new XPoint(100, 200), new XSize(300, 150)));
rsAnnot.Rectangle = new PdfRectangle(rect);

// Add the rubber stamp annotation to the page.

// Create a PDF link annotation            
rect = g.Transformer.WorldToDefaultPage(new XRect(new XPoint(100, 400), new XSize(300, 150)));
PdfLinkAnnotation linkAnnot = PdfLinkAnnotation.CreateWebLink(new PdfRectangle(rect), "http://www.xspdf.com");

// Save and show the document           

More PDF tutorial