Annotations

edit

Add markup annotations

The methods of PdfPage.Annotations add the annotations a reviewer adds to a document:

var annotations = page.Annotations;
var note = annotations.AddNote(new PdfPoint(40, 700), "Check this paragraph");
note.Author = "Reviewer";
annotations.AddTextMarkup(PdfTextMarkupKind.Highlight, [new PdfRectangle(72, 697, 175, 710)]);
annotations.AddFreeText(new PdfRectangle(300, 690, 500, 730), "Free text drawn on the page", fontSize: 10);
annotations.AddStamp(new PdfRectangle(400, 750, 550, 800), "APPROVED", PdfColor.FromRgb(0, 0.5, 0));
MethodAnnotation
AddNoteA note: an icon that opens a text
AddTextMarkupA highlight, an underline, a squiggly underline or a strikeout of regions of the page, one rectangle per line
AddFreeTextA text in a box, drawn on the page, in a standard font
AddStampA word in a frame with rounded corners, such as APPROVED or DRAFT
  • Each annotation has an appearance stream, so that every viewer shows and prints it the same way. A highlight is multiplied with the content, so that the text under it stays readable.
  • They return a PdfMarkupAnnotation: set its Author, Subject, CreationDate and Opacity. The markup annotations of a file (shapes, ink, lines...) are read as PdfMarkupAnnotation too.
  • Color is the color of any annotation; changing it does not change an appearance it already has.

Flags

Flags reads and changes the flags of an annotation: whether it is printed, hidden, shown on the screen, locked... The bits that PdfAnnotationFlags does not name are kept. The annotations the library creates are printed.

The order of the annotations

PdfPage.Annotations reads the annotations once, and again when the annotations of the page change: through the collection or the object model. An annotation is the same instance until then, and an indexed loop does not read them again on each iteration.