[]
        
(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. GcPdf provides TextMarkupAnnotation class to enable the users to apply text markup annotations to the PDF file.

image

TextMarkupAnnotation class provides the following properties to set various options for the text markup annotation:

Property

Description

UserName

Adds the user name to the text label in the title bar of the annotation’s pop-up window when the annotation is open and active.

Subject

Adds the text representing the subject of the annotation.

Contents

Adds the text to the annotation for display.

RichText

Adds the text to the annotation for display in the pop-up window when opened. You can format this text using HTML tags.

Opacity

Sets the opacity of the annotation.

Color

Sets the annotation color, popup window color, line color, etc.

MarkupType

Sets the markup type to Highlight, Squiggly, StrikeOut, or Underline.

Area

Adds the list of quadrilateral structures defining the markup area. The coordinates of the quadrilaterals' points are relative to the upper left corner of the page's media box, with the Y (vertical) coordinates increasing from top to bottom.

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");
}