Skip to main content
All docs
V22.2
.NET Framework 4.5.2+

PdfAnnotationFacade Class

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

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v22.2.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, add replies and reviews, flatten, and remove all available annotations. Refer to the following article 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

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.

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