Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

PdfPageFacade.AddCaretAnnotation(PdfRectangle) Method

Creates a caret annotation in the specified page rectangle.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Core

#Declaration

public PdfCaretAnnotationFacade AddCaretAnnotation(
    PdfRectangle rect
)

#Parameters

Name Type Description
rect PdfRectangle

A page area to add the caret annotation.

#Returns

Type Description
PdfCaretAnnotationFacade

An object that contains caret annotation properties.

#Example

The code sample below adds a caret annotation to the Xbox phrase:

caret annotation

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

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

    // Find the target phrase in the document
    string caretText = "Xbox";
    PdfTextSearchResults caretSearchResults = processor.FindText(caretText);

    if (caretSearchResults.Status == PdfTextSearchStatus.Found)
    {
      // Create a caret annotation
      PdfCaretAnnotationFacade caretAnnotation =
                pageFacade.AddCaretAnnotation(caretSearchResults.Rectangles[0].BoundingRectangle);
      caretAnnotation.Author = "Brian Zetc";
      caretAnnotation.Contents = "Trademark is missing";
    }

    // Save the result
    processor.SaveDocument("..\\..\\Result.pdf");
}
See Also