Skip to main content
All docs
V26.1
  • FreeTextAnnotation Class

    Contains members that manage free text annotations.

    Namespace: DevExpress.Docs.Pdf

    Assembly: DevExpress.Docs.Pdf.v26.1.dll

    Declaration

    public class FreeTextAnnotation :
        MarkupAnnotation

    Example

    How to: Create a Free Text Annotation

    The following code snippet creates two annotations - a text highlight and a free text annotation:

    DevExpress PDF Document API - Create Markup Annotations

    FileStream fs = File.OpenRead("Demo.pdf");
    var options = new LoadOptions();
    PdfDocument document = new PdfDocument(fs, options);
    
    List<TextSearchInfo> results = document.FindText("external PDF Viewer").ToList();
    
    foreach (var match in results.SelectMany(x => x.Matches)) {
        var rects = match.MatchFragments
            .Select(x => x.Rectangle)
            .ToList();
    
        TextMarkupAnnotation textMarkupAnnotationCommon = new(rects) {
            Color = PdfColor.Yellow,
            Title = "Brian Zetc",
            Content = "This is a highlight annotation.",
            Type = TextMarkupAnnotationType.Highlight
        };
    
        document.Pages[match.PageIndex].Annotations.Add(textMarkupAnnotationCommon);
    
        document.Pages[match.PageIndex].Annotations.Add(new FreeTextAnnotation(new RectangleF(10, 50, 100, 50)) {
            Color = PdfColor.Red,
            Title = "Brian Zetc",
            Content = "This is a free text annotation."
        });
    }
    document.Save(new FileStream("Demo2.pdf", FileMode.Create, FileAccess.Write));
    

    Implements

    Inheritance

    See Also