Skip to main content

SquareAnnotation Class

Defines a PDF square annotation.

Declaration

public class SquareAnnotation extends ShapeAnnotation

Remarks

CircleAnnotation and SquareAnnotation inherit from the ShapeAnnotation class and share the following style settings in addition to their geometric parameters:

Border Style

Method: setBorderStyle(AnnotationBorderStyle value)

Defines the appearance of the annotation outline.

Interior Color

Method: setInteriorColor(PdfColor value)

Defines the fill appearance inside closed shapes (such as circle, square, and polygon annotations).

Border Effect

Method: setBorderEffect(AnnotationBorderEffect value)

Specifies additional visual effects for the annotation border, such as glow or decorative effects.

Padding

Method: setPadding(Padding value)

Specifies the internal spacing between the annotation boundary and its content, such as title and comment text.

The following code snippet draws a square annotation:

 Square 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.*;

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();

            createSquareAnnotation(page);

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

                pdfDocument.save(channel);
            }
        }
    }

    static void createSquareAnnotation(Page page) {
        SquareAnnotation annotation = new SquareAnnotation(new RectangleF(50, 350, 540, 100));
        annotation.setTitle("Reviewer");
        annotation.setContent("Update this paragraph.");

        annotation.setColor(PdfColor.getBlue());
        annotation.setPadding(new Padding(12));

        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

SquareAnnotation(RectangleF bounds)

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

Declaration

public SquareAnnotation(RectangleF bounds)

Parameters

Name Type Description
bounds RectangleF

The square annotation bounds.