Skip to main content
All docs
V25.1
  • PdfPageFacade.AddTextMarkupAnnotation(PdfRectangle, PdfTextMarkupAnnotationType) Method

    Creates a text markup annotation for the text located in the specified page rectangle.

    Namespace: DevExpress.Pdf

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

    NuGet Package: DevExpress.Pdf.Core

    Declaration

    public PdfTextMarkupAnnotationFacade AddTextMarkupAnnotation(
        PdfRectangle rectangle,
        PdfTextMarkupAnnotationType style
    )

    Parameters

    Name Type Description
    rectangle PdfRectangle

    The rectangle with the text that should be annotated.

    style PdfTextMarkupAnnotationType

    The text markup annotation type.

    Returns

    Type Description
    PdfTextMarkupAnnotationFacade

    An object that contain text markup annotation properties.

    Remarks

    If a specified rectangle does not contain text, the annotation is not created and the method returns null.

    Example: Strike Out Text

    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
      PdfPageFacade page = processor.DocumentFacade.Pages[0];
    
      // Find the target phrase in a document
      string strikeOutText = "Xbox";
      PdfTextSearchResults strikeSearchResults = processor.FindText(strikeOutText);
    
      if (strikeSearchResults.Status == PdfTextSearchStatus.Found)
      {
    
          // Add a text annotation to this phrase
          PdfTextMarkupAnnotationFacade strikeOutAnnotation =
              page.AddTextMarkupAnnotation(strikeSearchResults.Rectangles[0].BoundingRectangle, 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);
      }
      // Save the result
      processor.SaveDocument("..\\..\\Result.pdf");
    
    }
    
    See Also