Skip to main content
All docs
V23.2

PdfPageFacade.AddTextAnnotation(PdfRectangle) Method

Adds a text annotation to the specified area on the page.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v23.2.Core.dll

NuGet Package: DevExpress.Pdf.Core

Declaration

public PdfTextAnnotationFacade AddTextAnnotation(
    PdfRectangle rect
)

Parameters

Name Type Description
rect PdfRectangle

A page area to add the text annotation.

Returns

Type Description
PdfTextAnnotationFacade

An object that contains text annotation properties.

Remarks

The code sample below creates a sticky note above a specific text:

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
  // Load a document
  processor.LoadDocument("..\\..\\Document.pdf");

  // Access the first page properties
  PdfPageFacade page = processor.DocumentFacade.Pages[0];

  // Find the target phrase in a document
  string text = "Xbox";
  PdfTextSearchResults searchResults = processor.FindText(text);

  if (searchResults.Status == PdfTextSearchStatus.Found)
  {
      // Add a sticky note to this phrase
      PdfTextAnnotationFacade stickyNote =
          page.AddTextAnnotation(searchResults.Rectangles[0].BoundingRectangle);

      // Specify annotation properties
      stickyNote.Author = "Bill Smith";
      stickyNote.Subject = "Important!";
      stickyNote.Contents = "Please, fact-check this reference";
      stickyNote.Color = new PdfRGBColor(0.10, 0.85, 1.00);
  }
  // Save the result
  processor.SaveDocument("..\\..\\Result.pdf");

}
See Also