All docs
V21.2
21.2
21.1
The page you are viewing does not exist in version 21.1. This link will take you to the root page.
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PdfCaretAnnotationFacade Class

Contains members used to manage caret annotations without access to their inner structure.

Namespace: DevExpress.Pdf

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

Declaration

public class PdfCaretAnnotationFacade :
    PdfMarkupAnnotationFacade

Remarks

Create Caret Annotations

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

Edit Caret Annotations

The PdfPageFacade.Annotations property returns all page annotation properties. You can filter caret annotation properties, cast them to the PdfCaretAnnotationFacade class, and use class properties to modify annotation parameters.

The code sample below changes the color of all caret annotations:

caret annotation

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

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

    // Retrieve all caret annotations
    var caretAnnotations = pageFacade.Annotations.Where
            (annotation => annotation.Type == PdfAnnotationType.Caret);
    foreach (PdfCaretAnnotationFacade pdfCaret in caretAnnotations) 
    {
        // Change the annotation color
        pdfCaret.Color = new PdfRGBColor(0.90, 0.00, 0.30);
    }
    // Save the result
    processor.SaveDocument("..\\..\\Result.pdf");
}

Flatten Caret Annotations

Call one of the following methods to flatten an annotation:

Method Description
PdfDocumentFacade.FlattenAnnotations Flattens document annotations.
PdfPageFacade.FlattenAnnotations Flattens annotations of a specific page.
PdfAnnotationFacade.Flatten() Flattens a specific annotation.

The code sample below flattens all caret annotations on the first page:

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

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

    // Flatten all caret annotations
    page.FlattenAnnotations(PdfAnnotationType.Caret);
}

Remove Caret Annotations

Call the PdfAnnotationFacade.Remove() method to remove an annotation. The code sample below removes all caret annotations on the first page:

using DevExpress.Pdf;
using System.Linq;

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{

  // Load a document
  processor.LoadDocument("..\\..\\Document.pdf");

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

  // Retrieve all caret annotations
  var caretAnnotations = page.Annotations.Where
    (annotation => annotation.Type == PdfAnnotationType.Caret).ToList();

  // Remove all caret annotations
  foreach (PdfInkAnnotationFacade caret in caretAnnotations)
  {
      caret.Remove();
  }
}

Inheritance

See Also