Skip to main content
All docs
V25.1
  • PdfAnnotationFacade Class

    Exposes members used to organize annotations without access to their inner structure.

    Namespace: DevExpress.Pdf

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

    NuGet Package: DevExpress.Pdf.Core

    Declaration

    public class PdfAnnotationFacade

    Remarks

    Use the PdfPageFacade.Annotations property to retrieve a list of annotation objects.

    Our Annotation Facade API allows you to add, edit, flatten, and remove annotations. You can also add replies and reviews to annotations. Refer to the following help topic for more information about annotations: Annotations in PDF Documents.

    Create Annotations

    The table below lists available annotation types and API used to create these annotations. You can filter annotation properties, cast them to the corresponding class, and use class properties to modify annotation parameters.

    Annotation Class Method
    Link PdfLinkAnnotationFacade PdfPageFacade.AddLinkAnnotation
    Text Markup PdfTextMarkupAnnotationFacade PdfPageFacade.AddTextMarkupAnnotation
    Sticky Note PdfTextAnnotationFacade PdfPageFacade.AddTextAnnotation
    Caret PdfCaretAnnotationFacade PdfPageFacade.AddCaretAnnotation
    Rubber Stamp PdfRubberStampAnnotationFacade PdfPageFacade.AddRubberStampAnnotation
    Circle PdfCircleAnnotationFacade PdfPageFacade.AddCircleAnnotation
    Square PdfSquareAnnotationFacade PdfPageFacade.AddSquareAnnotation
    File Attachment PdfFileAttachmentAnnotationFacade PdfPageFacade.AddFileAttachmentAnnotation
    Free Text PdfFreeTextAnnotationFacade PdfPageFacade.AddFreeTextAnnotation
    Ink PdfInkAnnotationFacade PdfPageFacade.AddInkAnnotation
    Line PdfLineAnnotationFacade PdfPageFacade.AddLineAnnotation
    Polyline PdfPolyLineAnnotationFacade PdfPageFacade.AddPolyLineAnnotation
    Polygon PdfPolygonAnnotationFacade PdfPageFacade.AddPolygonAnnotation
    Redaction PdfRedactAnnotationFacade PdfPageFacade.AddRedactAnnotation

    Flatten 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.

    Note

    When you call one of the Flatten… methods for redaction annotations, their overlay parameters (text, fill color, and so on) are not applied and the redacted content in not removed. Use one of the ApplyRedactAnnotations methods to apply these annotations.

    The code sample below flattens all text annotations in the document:

    using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
    {
      // Load a document:
      processor.LoadDocument("..\\..\\Document.pdf");
    
      // Flatten all text annotations:
      PdfDocumentFacade documentFacade = processor.DocumentFacade;
      documentFacade.FlattenAnnotations(PdfAnnotationType.Text);
    
      // Save the result:
      processor.SaveDocument("..\\..\\Result.pdf");
    }
    

    Remove Annotations

    Call the Remove() method to remove an annotation.

    The code sample below removes all annotations from a specific author:

    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 markup annotations
        var markups = pageFacade.Annotations.Where
                (annotation => annotation.Type != PdfAnnotationType.Link).ToList();
        foreach(PdfMarkupAnnotationFacade markupAnnotation in markups)
        {
            // Check the annotation author
            if (markupAnnotation.Author == "Brian Zetc")
            {
                // Remove the annotation
                markupAnnotation.Remove();
            }
        }
        // Save the result
        processor.SaveDocument("..\\..\\Result.pdf");
    }
    
    See Also