Add button component
Leave feedback
On this page
Button component creates a button component as shown in the picture below:
You can specify the following properties of the ButtonComponent class:
To add a button component, follow these steps:
- Instantiate the Annotator class. Specify the input document path or stream.
- Instantiate the ButtonComponent class. Specify the appropriate properties (position, page number, etc).
- Call the Add method. Specify the ButtonComponent class.
- Call the Save method. Specify the output document path or stream.
The following code snippet shows how to add ButtonComponent to the document:
try(final Annotator annotator = new Annotator(Constants.INPUT_PDF)) {
ButtonComponent buttonComponent = new ButtonComponent();
buttonComponent.setCreatedOn(new Date());
buttonComponent.setStyle(BorderStyle.DASHED);
buttonComponent.setMessage("This is button component");
buttonComponent.setBorderColor(1422623);
buttonComponent.setPenColor(14527697);
buttonComponent.setButtonColor(10832612);
buttonComponent.setPageNumber(0);
buttonComponent.setBorderWidth(12);
buttonComponent.setBox(new Rectangle(100, 300, 90, 30));
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);
buttonComponent.setReplies(replies);
annotator.add(buttonComponent);
annotator.save("result_button_component.pdf");
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.