Add dropdown component

On this page

Dropdown component creates a combo box as shown in the picture below:

You can specify the following properties of the DropdownComponent class:

  • Box defines the annotation position
  • PenColor defines the frame color
  • PenStyle defines the frame line style (solid, dash, dot etc.)
  • PenWidth defines the frame line width in pixels.

To add a dropdown component, follow these steps:

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

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

using (Annotator annotator = new Annotator("input.pdf"))
{
	DropdownComponent dropdown = new DropdownComponent
    {
        Options = new List<string> { "Item1", "Item2", "Item3" },
        SelectedOption = null,
        Placeholder = "Choose option",
        Box = new Rectangle(100, 100, 100, 100),
        CreatedOn = DateTime.Now,
        Message = "This is dropdown component",
        PageNumber = 0,
        PenColor = 65535,
        PenStyle = PenStyle.Dot,
        PenWidth = 3,
        Replies = new List<Reply>
        {
            new Reply
            {
                Comment = "First comment",
                RepliedOn = DateTime.Now
            },
            new Reply
            {
                Comment = "Second comment",
                RepliedOn = DateTime.Now
            }
        }
    };
    annotator.Add(dropdown);
    annotator.Save("result.pdf");
}

On this page