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+

PdfTextMarkupAnnotationFacade Class

Contains members used to manage text markup annotations (text highlights) without access to their inner structure.

Namespace: DevExpress.Pdf

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

Declaration

public class PdfTextMarkupAnnotationFacade :
    PdfMarkupAnnotationFacade

Remarks

Create Text Markup Annotations

The code sample below strikes out specific text in the document:

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

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

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

  if (strikeSearchResults.Status == PdfTextSearchStatus.Found)
  {

      // Add text markup annotation to this phrase
      PdfTextMarkupAnnotationFacade strikeOutAnnotation =
          page.AddTextMarkupAnnotation(strikeSearchResults.Rectangles[0], PdfTextMarkupAnnotationType.StrikeOut);

      // Specify annotation properties
      strikeOutAnnotation.Author = "Bill Smith";
      strikeOutAnnotation.Subject = "Important!";
      strikeOutAnnotation.Contents = "Please, fact-check this reference";
      strikeOutAnnotation.Color = new PdfRGBColor(0.10, 0.85, 1.00);
  }
}

Edit Text Markup Annotations

The PdfPageFacade.Annotations property retrieves all annotations on the page. You can filter text markup annotation properties, cast them to the PdfTextMarkupAnnotationFacade class, and use class properties to modify annotation parameters.

The code sample below changes the markup type and color of all text markup 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 text markup annotations
  var textMarkups = page.Annotations.Where
    (annotation => annotation.Type == PdfAnnotationType.TextMarkup);

  // Change annotation parameters
  foreach (PdfTextMarkupAnnotationFacade markup in textMarkups)
  {
    markup.MarkupType = PdfTextMarkupAnnotationType.Squiggly;
    markup.Color = new PdfRGBColor(0.10, 0.85, 1.00);
  }
  // Save the result
  processor.SaveDocument("..\\..\\Result.pdf");
}

Flatten Text Markup 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 text markup 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 text markups
  page.FlattenAnnotations(PdfAnnotationType.TextMarkup);

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

Remove Text Markup Annotations

Call the PdfAnnotationFacade.Remove() method to remove a specific annotation.

The code sample below removes all text markup annotations from 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];

  // Retrieve all text markup annotations
  var textMarkups = page.Annotations.Where
    (annotation => annotation.Type == PdfAnnotationType.TextMarkup).ToList();

  foreach (PdfTextMarkupAnnotationFacade markup in textMarkups)
  {
    // Remove each annotation
    markup.Remove();
  }
  // Save the result
  processor.SaveDocument("..\\..\\Result.pdf");
}

Inheritance

See Also