Skip to main content
A newer version of this page is available. .
All docs
V23.1
.NET Framework 4.5.2+

PdfPageFacade.AddTextMarkupAnnotation(IEnumerable<PdfOrientedRectangle>, PdfTextMarkupAnnotationType) Method

Creates a text markup annotation at the specified page area.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Core

Declaration

public PdfTextMarkupAnnotationFacade AddTextMarkupAnnotation(
    IEnumerable<PdfOrientedRectangle> textRectangles,
    PdfTextMarkupAnnotationType style
)

Parameters

Name Type Description
textRectangles IEnumerable<PdfOrientedRectangle>

A collection of rectangles that specify a page area where the annotation should be located.’

style PdfTextMarkupAnnotationType

The text markup annotation type.

Returns

Type Description
PdfTextMarkupAnnotationFacade

An object that contain text markup annotation properties.

Remarks

This method returns null if the collection of PdfOrientedRectangle objects is empty.

The code sample below highlights a specific text in the document:

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

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

  // Find the phrase to highlight
  string annotatedText =
    "We estimate that each component of Ounce provides independent pseudorandom theory.";
  PdfTextSearchResults searchResults = pdfDocumentProcessor.FindText(annotatedText);

  if (searchResults.Status == PdfTextSearchStatus.Found)
  {
      // Highlight found text
      PdfTextMarkupAnnotationFacade textMarkupAnnotation =
          page.AddTextMarkupAnnotation(searchResults.Rectangles, PdfTextMarkupAnnotationType.Highlight);

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

}
See Also