All docs
V21.2
21.2
21.1
The page you are viewing does not exist in version 21.1. This link will take you to the root page.
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PdfPolygonAnnotationFacade Class

Contains members used to manage polygon annotations without access to their inner structure.

Namespace: DevExpress.Pdf

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

Declaration

public class PdfPolygonAnnotationFacade :
    PdfPathAnnotationFacade

Remarks

Create Polygon Annotations

The code sample below creates a hexagon:

hexagon

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

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

    // Define hexagon vertices
    PdfPoint point1 = new PdfPoint(150, 150);
    PdfPoint point2 = new PdfPoint(140, 160);
    PdfPoint point3 = new PdfPoint(150, 170);
    PdfPoint point4 = new PdfPoint(160, 170);
    PdfPoint point5 = new PdfPoint(170, 160);
    PdfPoint point6 = new PdfPoint(160, 150);
    PdfPoint[] points = new PdfPoint[] { point1, point2, point3, point4, point5, point6 };

    // Create a hexagon annotation
    PdfPolygonAnnotationFacade hexagon = pageFacade.AddPolygonAnnotation(points);
    hexagon.Author = "Cardle Anita W";

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

Edit Polygon Annotations

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

The code sample below retrieves all polygon annotations on the first page and changes their parameters:

polygon edited

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 polygon annotations
    var polygons = pageFacade.Annotations.Where
      (annotation => annotation.Type == PdfAnnotationType.Polygon);
    foreach (PdfPolygonAnnotationFacade polygon in polygons) 
    {
        // Change polygon parameters
        polygon.BorderWidth = 4;
        polygon.InteriorColor = new PdfRGBColor(0.40, 0.90, 1.00);
        polygon.Color = new PdfRGBColor(0.20, 0.20, 1.00);
        polygon.Contents = "Made by PDF Document API";
    }

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

Flatten Polygon 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 polygon annotations on the first page:

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 polygon annotations
    pageFacade.FlattenAnnotations(PdfAnnotationType.Polygon);

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

Remove Polygon Annotations

Call the PdfAnnotationFacade.Remove() method to remove an annotation. The code sample below removes all polygon annotations 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 pageFacade = processor.DocumentFacade.Pages[0];

    // Retrieve all polygon annotations
    var polygons = pageFacade.Annotations.Where
      (annotation => annotation.Type == PdfAnnotationType.Polygon).ToList();
    foreach (PdfPolygonAnnotationFacade polygon in polygons) 
    {
        // Remove all polygons
        polygon.Remove();
    }

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