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:

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
Inheritance
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. |