Add checkbox component

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:

using (Annotator annotator = new Annotator("input.pdf"))
{
	CheckBoxComponent checkbox = new CheckBoxComponent
    {
        Checked = true,
        Box = new Rectangle(100, 100, 100, 100),
        PenColor = 65535,
        Style = BoxStyle.Star,
        Replies = new List<Reply>
            {
                new Reply
                {
                    Comment = "First comment",
                    RepliedOn = DateTime.Now
                },
                new Reply
                {
                    Comment = "Second comment",
                    RepliedOn = DateTime.Now
                }
            }
    };
    annotator.Add(checkbox);
    annotator.Save("result.pdf");
}

On this page