Skip to main content

PolygonAnnotation Class

Defines a PDF polygon annotation.

Declaration

public class PolygonAnnotation extends PathAnnotation

Remarks

The following code snippet draws a polygon annotation:

Polygon Annotation, DevExpress PDF Document API for Java

package pdf;

import com.devexpress.docs.*;
import com.devexpress.docs.pdf.*;
import com.devexpress.system.drawing.*;

import java.nio.channels.*;
import java.nio.file.*;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        try (FileChannel fileChannel = FileChannel.open(Path.of("Office-Floor-Plan.pdf"));
             PdfDocument pdfDocument = new PdfDocument(fileChannel)) {

            Page page = pdfDocument.getPages().getFirst();

            createPolygonAnnotation(page);

            try (WritableByteChannel channel =
                         FileChannel.open(Path.of("Result.pdf"),
                                 StandardOpenOption.CREATE,
                                 StandardOpenOption.WRITE,
                                 StandardOpenOption.TRUNCATE_EXISTING)) {

                pdfDocument.save(channel);
            }
        }
    }

    static void createPolygonAnnotation(Page page) {
        List<PointF> vertices = List.of(
                new PointF(120, 450),
                new PointF(520, 450),
                new PointF(520, 300),
                new PointF(400, 300),
                new PointF(400, 370),
                new PointF(120, 370));

        PolygonAnnotation annotation = new PolygonAnnotation(vertices);

        annotation.setTitle("Reviewer");
        annotation.setContent("Review this area.");
        annotation.setColor(PdfColor.getOrange());

        page.getAnnotations().add(annotation);
    }
}

Refer to the following help topic for additional information: Drawing Annotations.

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object

PolygonAnnotation(List<PointF> vertices)

Initializes a new instance of the PolygonAnnotation class with specified vertices.

Declaration

public PolygonAnnotation(List<PointF> vertices)

Parameters

Name Type Description
vertices java.util.List<com.devexpress.system.drawing.PointF>

The polygon annotation vertices.

Methods

getBorderEffect() Method

Returns the polygon annotation border effect.

Declaration

public AnnotationBorderEffect getBorderEffect()

Returns

Type Description
AnnotationBorderEffect

The polygon annotation border effect.

getPolygonIntent() Method

Returns the polygon annotation intent.

Declaration

public PolygonAnnotationIntent getPolygonIntent()

Returns

Type Description
PolygonAnnotationIntent

The polygon annotation intent.

setBorderEffect(AnnotationBorderEffect value) Method

Sets the polygon annotation border effect.

Declaration

public void setBorderEffect(AnnotationBorderEffect value)

Parameters

Name Type Description
value AnnotationBorderEffect

The polygon annotation border effect.

setPolygonIntent(PolygonAnnotationIntent value) Method

Sets the polygon annotation intent.

Declaration

public void setPolygonIntent(PolygonAnnotationIntent value)

Parameters

Name Type Description
value PolygonAnnotationIntent

The polygon annotation intent.