Back to Devexpress

PdfAnnotationFacade Class

officefileapi-devexpress-dot-pdf-02e3d259.md

latest9.8 KB
Original Source

PdfAnnotationFacade Class

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

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public class PdfAnnotationFacade
vb
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.

AnnotationClassMethod
LinkPdfLinkAnnotationFacadePdfPageFacade.AddLinkAnnotation
Text MarkupPdfTextMarkupAnnotationFacadePdfPageFacade.AddTextMarkupAnnotation
Sticky NotePdfTextAnnotationFacadePdfPageFacade.AddTextAnnotation
CaretPdfCaretAnnotationFacadePdfPageFacade.AddCaretAnnotation
Rubber StampPdfRubberStampAnnotationFacadePdfPageFacade.AddRubberStampAnnotation
CirclePdfCircleAnnotationFacadePdfPageFacade.AddCircleAnnotation
SquarePdfSquareAnnotationFacadePdfPageFacade.AddSquareAnnotation
File AttachmentPdfFileAttachmentAnnotationFacadePdfPageFacade.AddFileAttachmentAnnotation
Free TextPdfFreeTextAnnotationFacadePdfPageFacade.AddFreeTextAnnotation
InkPdfInkAnnotationFacadePdfPageFacade.AddInkAnnotation
LinePdfLineAnnotationFacadePdfPageFacade.AddLineAnnotation
PolylinePdfPolyLineAnnotationFacadePdfPageFacade.AddPolyLineAnnotation
PolygonPdfPolygonAnnotationFacadePdfPageFacade.AddPolygonAnnotation
RedactionPdfRedactAnnotationFacadePdfPageFacade.AddRedactAnnotation

Flatten Annotations

Call one of the following methods to flatten an annotation:

MethodDescription
PdfDocumentFacade.FlattenAnnotationsFlattens document annotations.
PdfPageFacade.FlattenAnnotationsFlattens 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:

csharp
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");
}
vb
Using processor As New PdfDocumentProcessor()
  ' Load a document:
  processor.LoadDocument("..\..\Document.pdf")

  ' Flatten all text annotations:
  Dim documentFacade As PdfDocumentFacade = processor.DocumentFacade
  documentFacade.FlattenAnnotations(PdfAnnotationType.Text)

  ' Save the result:
  processor.SaveDocument("..\..\Result.pdf")
End Using

Remove Annotations

Call the Remove() method to remove an annotation.

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

csharp
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");
}
vb
Imports DevExpress.Pdf
Imports System.Linq

Using processor As New PdfDocumentProcessor()
  ' Load a document
  processor.LoadDocument("..\..\Document.pdf")

  ' Access the first page properties
  Dim pageFacade As PdfPageFacade = processor.DocumentFacade.Pages(0)

  ' Retrieve all markup annotations
  Dim markups = pageFacade.Annotations.Where
    (Function(annotation) annotation.Type <> PdfAnnotationType.Link).ToList()
  For Each markupAnnotation As PdfMarkupAnnotationFacade In markups

    ' Check the annotation author
    If markupAnnotation.Author = "Brian Zetc" Then

      ' Remove the annotation
      markupAnnotation.Remove()
    End If
  Next markupAnnotation

  ' Save the result
  processor.SaveDocument("..\..\Result.pdf")
End Using

Inheritance

Show 20 items

Object PdfAnnotationFacade PdfLinkAnnotationFacade

PdfMarkupAnnotationFacade

PdfFreeTextAnnotationFacade

PdfCaretAnnotationFacade

PdfCircleAnnotationFacade

PdfInkAnnotationFacade

PdfLineAnnotationFacade

PdfTextMarkupAnnotationFacade

PdfPathAnnotationFacade

PdfPolygonAnnotationFacade

PdfPolyLineAnnotationFacade

PdfRedactAnnotationFacade

PdfFileAttachmentAnnotationFacade

PdfRubberStampAnnotationFacade

PdfShapeAnnotationFacade

PdfSoundAnnotationFacade

PdfSquareAnnotationFacade

PdfTextAnnotationFacade

See Also

PdfAnnotationFacade Members

DevExpress.Pdf Namespace