Add checkbox component

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Annotation MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-annotation -- dnx GroupDocs.Annotation.Mcp --yes
Folders, licensing and more →

On this page

Checkbox component creates a checkbox as shown in the picture below:

You can specify the following properties of the CheckBoxComponent class:

  • Box defines the annotation position
  • PenColor defines the frame color

To add a checkbox component, follow these steps:

  1. Instantiate the Annotator class. Specify the input document path or stream.
  2. Instantiate the CheckboxComponent class. Specify the appropriate properties (position, page number, etc).
  3. Call the Add method. Specify the CheckboxComponent class.
  4. Call the Save method. Specify the output document path or stream.

The following code snippet shows how to add CheckboxComponent to the document:

try(final Annotator annotator = new Annotator(Constants.INPUT_PDF)) {
	CheckBoxComponent checkbox = new CheckBoxComponent();
	checkbox.setChecked(true);
	checkbox.setBox(new Rectangle(100, 100, 100, 100));
	checkbox.setPenColor(65535);
	checkbox.setStyle(BoxStyle.STAR);
	Reply reply1 = new Reply();
	reply1.setComment("First comment");
	reply1.setRepliedOn(new Date());

	Reply reply2 = new Reply();
	reply2.setComment("Second comment");
	reply2.setRepliedOn(new Date());

	List<Reply> replies = new ArrayList<>();
	replies.add(reply1);
	replies.add(reply2);

	checkbox.setReplies(replies);

	annotator.add(checkbox);
	annotator.save("result_checkbox_component.pdf");
}

On this page