Skip to main content

PolylineAnnotation Class

Defines a PDF polyline annotation.

Declaration

public class PolylineAnnotation extends UnclosedPathAnnotation

Remarks

The following code snippet draws a polyline annotation:

Polyline Annotation, 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();

            createPolylineAnnotation(page);

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

                pdfDocument.save(channel);
            }
        }
    }

    static void createPolylineAnnotation(Page page) {
        List<PointF> vertices = List.of(
                new PointF(140, 450),
                new PointF(350, 450),
                new PointF(500, 600));

        PolylineAnnotation annotation = new PolylineAnnotation(vertices);

        annotation.setTitle("HR");
        annotation.setContent("Follow this path to the break room.");
        annotation.setColor(PdfColor.getGreen());
        annotation.setFinishLineEnding(AnnotationLineEndingStyle.OPEN_ARROW);

        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

PolylineAnnotation(List<PointF> vertices)

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

Declaration

public PolylineAnnotation(List<PointF> vertices)

Parameters

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

The polyline annotation vertices.

Methods

getPolylineIntent() Method

Returns the polyline annotation intent.

Declaration

public PolylineAnnotationIntent getPolylineIntent()

Returns

Type Description
PolylineAnnotationIntent

The polyline annotation intent.

setPolylineIntent(PolylineAnnotationIntent value) Method

Sets the polyline annotation intent.

Declaration

public void setPolylineIntent(PolylineAnnotationIntent value)

Parameters

Name Type Description
value PolylineAnnotationIntent

The polyline annotation intent.