Back to Devexpress

PdfCircleAnnotationFacade Class

officefileapi-devexpress-dot-pdf-86e82432.md

latest8.4 KB
Original Source

PdfCircleAnnotationFacade Class

Exposes members used to organize circle 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 PdfCircleAnnotationFacade :
    PdfShapeAnnotationFacade
vb
Public Class PdfCircleAnnotationFacade
    Inherits PdfShapeAnnotationFacade

The following members return PdfCircleAnnotationFacade objects:

Remarks

Create Circle Annotations

The code sample below creates a circle annotation:

csharp
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    // Load a document
    processor.LoadDocument("..\\..\\Document.pdf");

    // Access the first page properties
    PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];

    // Define an annotation area
    PdfRectangle rectangle = new PdfRectangle(663, 526, 763, 576);

    // Create a circle annotation
    PdfCircleAnnotationFacade circleAnnotation = pageFacade.AddCircleAnnotation(rectangle);

    // Specify annotation parameters
    circleAnnotation.Author = "Nancy Davolio";
    circleAnnotation.Contents = "Made in PDF Document API";

    // Save the result
    processor.SaveDocument("..\\..\\Result.pdf");
}
vb
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)

  ' Define an annotation area
  Dim rectangle As New PdfRectangle(663, 526, 763, 576)

  ' Create a circle annotation
  Dim circleAnnotation As PdfCircleAnnotationFacade = pageFacade.AddCircleAnnotation(rectangle)

  ' Specify annotation parameters
  circleAnnotation.Author = "Nancy Davolio"
  circleAnnotation.Contents = "Made in PDF Document API"

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

Edit Circle Annotations

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

The code sample below retrieves all circle annotations on the first page and changes their border and fill color.

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 circle annotations
    var circleAnnotations = pageFacade.Annotations.Where
      (annotation => annotation.Type == PdfAnnotationType.Circle);
    foreach (PdfCircleAnnotationFacade circleAnnotation in circleAnnotations)
    {
        // Change annotation parameters
        circleAnnotation.Color = new PdfRGBColor(1,1,1); 
        circleAnnotation.InteriorColor = new PdfRGBColor(0.87, 0.60, 1.00); 
    }
    // 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 circle annotations
  Dim circleAnnotations = pageFacade.Annotations.Where(Function(annotation) annotation.Type = PdfAnnotationType.Circle)
  For Each circleAnnotation As PdfCircleAnnotationFacade In circleAnnotations
    ' Change annotation parameters
    circleAnnotation.Color = New PdfRGBColor(1,1,1);
    circleAnnotation.InteriorColor = New PdfRGBColor(0.87, 0.60, 1.00)
  Next circle
  ' Save the result
  processor.SaveDocument("..\..\Result.pdf")
End Using

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

The code sample below flattens all circle annotations on the first page:

csharp
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    // Load a document
    processor.LoadDocument("..\\..\\Document.pdf");

    // Access the first page properties
    PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];

    // Flatten all circle annotations
    pageFacade.FlattenAnnotations(PdfAnnotationType.Circle);

    // Save the result
    processor.SaveDocument("..\\..\\Result.pdf");
}
vb
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)

  ' Flatten all circle annotations
  pageFacade.FlattenAnnotations(PdfAnnotationType.Circle)

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

Remove Circle Annotations

Call the PdfAnnotationFacade.Remove() method to remove a specific annotation.

The code sample below removes all circle annotations from the first page:

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 circle annotations
    var circleAnnotations = pageFacade.Annotations.Where
      (annotation => annotation.Type == PdfAnnotationType.Circle).ToList();
    foreach (PdfCircleAnnotationFacade circle in circleAnnotations)
    {
        // Remove each annotation
        circle.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 circle annotations
  Dim circleAnnotations = pageFacade.Annotations.Where
    (Function(annotation) annotation.Type = PdfAnnotationType.Circle).ToList()
  For Each circle As PdfCircleAnnotationFacade In circleAnnotations
    ' Remove each annotation
    circle.Remove()
  Next circle
  ' Save the result
  processor.SaveDocument("..\..\Result.pdf")
End Using

Inheritance

Object PdfAnnotationFacade PdfMarkupAnnotationFacade PdfShapeAnnotationFacade PdfCircleAnnotationFacade

See Also

PdfCircleAnnotationFacade Members

DevExpress.Pdf Namespace