Skip to main content
All docs
V23.2

PdfTextAnnotationFacade Class

Contains members used to manage text annotations (sticky notes) without access to their inner structure.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Core

Declaration

public class PdfTextAnnotationFacade :
    PdfMarkupAnnotationFacade

Remarks

Create Text Annotations

The code sample below creates a sticky note at the specified point 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];

  // Add sticky note at the specified point
  PdfTextAnnotationFacade textAnnotation =
     page.AddTextAnnotation(new PdfPoint(64, 65), PdfTextAnnotationIconName.Cross);

  // Specify annotation parameters
  textAnnotation.Author = "Nancy Davolio";
  textAnnotation.Color = new PdfRGBColor(0.8, 0.2, 0.1);
  textAnnotation.Contents = "Please proofread this document";
}

Edit Text Annotations

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

The code sample below retrieves all sticky notes on the first page and changes their icon, color and opacity:

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 sticky notes
  var stickyNotes = page.Annotations.Where
    (annotation => annotation.Type == PdfAnnotationType.Text);
  foreach (PdfTextAnnotationFacade stickyNote in stickyNotes)
  {
      // Change annotation parameters
      stickyNote.IconName = PdfTextAnnotationIconName.Note;
      stickyNote.Opacity = 0.7;
      stickyNote.Color = new PdfRGBColor(0.10, 0.85, 1.00);
  }
  // Save the result
  processor.SaveDocument("..\\..\\Result.pdf");
}

Flatten Text 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 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 annotations
    page.FlattenAnnotations(PdfAnnotationType.Text);

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

Remove Text Annotations

Call the PdfAnnotationFacade.Remove() method to remove an annotation. The code sample below removes all sticky motes from 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 sticky notes
  var stickyNotes = page.Annotations.Where
    (annotation => annotation.Type == PdfAnnotationType.Text).ToList();
  foreach (PdfTextAnnotationFacade stickyNote in stickyNotes)
  {
      // Remove each annotation
      stickyNote.Remove();
  }
  // Save the result
  processor.SaveDocument("..\\..\\Result.pdf");
}

Inheritance

See Also