[]
        
(Showing Draft Content)

Text Markup Annotation

Text markup annotations is the simplest type of markup annotation for marking up page text. Text markup annotation appears as underlines, highlights, strikeouts or jagged underlines in the document's text. DsPdf provides TextMarkupAnnotation class to enable the users to apply text markup annotations to the PDF file.

DsPdf demonstrating how to add text markup annotation in a PDF document

Refer to the following example code to add a text markup annotation to a PDF document:

public void CreateTextMarkupAnnotation()
{
    GcPdfDocument doc = new GcPdfDocument();
    var page = doc.NewPage();
    var tl = page.Graphics.CreateTextLayout();
    tl.DefaultFormat.Font = StandardFonts.Times;
    tl.DefaultFormat.FontSize = 14;
    tl.Append("This sample demonstrates how you can create Text markup annotation.");
    page.Graphics.DrawTextLayout(tl, new PointF(72, 72));

    //Create an instance of TextMarkupAnnotation class and set its relevant properties
    var textMarkupAnnot = new TextMarkupAnnotation();
    textMarkupAnnot.MarkupType = TextMarkupType.Highlight;
    textMarkupAnnot.UserName = "Jaime Smith";
    textMarkupAnnot.Contents = "This is a Text markup annotation";
    //search the text(e.g employee name) which needs to be redacted
    var found = doc.FindText(new FindTextParams("Text markup", true, false), null);
    List<Quadrilateral> area = new List<Quadrilateral>();
    foreach (var f in found)
        area.Add(f.Bounds[0]);
    textMarkupAnnot.Area = area;
    textMarkupAnnot.Color = Color.Yellow;

    page.Annotations.Add(textMarkupAnnot); //Add the text markup annotation to the page
    doc.Save("TextMarkupAnnotation.pdf");
}