Adding JavaScript to a CheckBox Field

Skip to end of metadata
Go to start of metadata
Adding JavaScript to a CheckBox Field

You can use JavaScript with the CheckBox fields with the help of Aspose.Pdf.Kit for Java. This component allows you to add JavaScript to a CheckBox field. You can also get the JavaScript from the field into a String variable. Removing the JavaScript from the CheckBox field is also feasible. The code snippets given below show you how to work with all of the three scenarios mentioned above.

This example shows you how to add JavaScript to a CheckBox:

[Java]
//Add JavaScript to a CheckBox Field
Form pdfForm = new Form("input.pdf","output.pdf");
pdfForm.setJavaScript("CheckBox","app.alert('Hello World');");
pdfForm.save();
 

This example shows you how to get JavaScript from a CheckBox:

[Java]
//Get JavaScript from a CheckBox Field
Form pdfForm = new Form("input.pdf");
String javaScript = pdfForm.getJavaScript("CheckBox");
System.out.println("JavaScript : " + javaScript);
 

This example shows you how to remove JavaScript from a CheckBox:

[Java]
//Remove JavaScript from a CheckBox Field
Form pdfForm = new Form("input.pdf","output.pdf");
pdfForm.removeJavaScript("CheckBox");
pdfForm.save();
 
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.