Skip to main content

InkAnnotation Class

Defines an ink annotation.

Declaration

public class InkAnnotation extends MarkupAnnotation

Remarks

Ink annotations display handwritten marks or freeform drawing paths on a PDF page.

The following code snippet adds a freehand drawing to the first page:

Ink Annotation, DevExpress PDF Document API for Java

package pdf;

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("Document.pdf"));
             PdfDocument pdfDocument = new PdfDocument(fileChannel)) {

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

            createInkAnnotation(page);

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

                pdfDocument.save(channel);
            }
        }
    }

    static void createInkAnnotation(Page page) {
        List<PointF[]> inks = List.of(
                new PointF[] { new PointF(100, 300),
                        new PointF(120, 290),
                        new PointF(150, 305),
                        new PointF(180, 295)
                },
                new PointF[] {
                        new PointF(210, 320),
                        new PointF(240, 340),
                        new PointF(270, 330)
                }
        );

        InkAnnotation annotation = new InkAnnotation(new RectangleF(80, 780, 260, 120));
        annotation.setInks(inks);
        annotation.setTitle("Reviewer");
        annotation.setContent("Handwritten note.");
        annotation.setColor(PdfColor.getBlue());

        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
JavaObject

InkAnnotation(RectangleF bounds)

Initializes a new instance of the InkAnnotation class with specified bounds.

Declaration

public InkAnnotation(RectangleF bounds)

Parameters

Name Type Description
bounds RectangleF

The annotation bounds.

Methods

getBorderStyle() Method

Returns the ink annotation border style.

Declaration

public AnnotationBorderStyle getBorderStyle()

Returns

Type Description
AnnotationBorderStyle

The ink annotation border style.

getInks() Method

Returns the ink annotation paths.

Declaration

public List<PointF[]> getInks()

Returns

Type Description
java.util.List<com.devexpress.system.drawing.PointF[]>

The ink annotation paths.

setBorderStyle(AnnotationBorderStyle value) Method

Sets the ink annotation border style.

Declaration

public void setBorderStyle(AnnotationBorderStyle value)

Parameters

Name Type Description
value AnnotationBorderStyle

The ink annotation border style.

setInks(List<PointF[]> value) Method

Sets the ink annotation paths.

Declaration

public void setInks(List<PointF[]> value)

Parameters

Name Type Description
value java.util.List<com.devexpress.system.drawing.PointF[]>

The ink annotation paths.