DynamicPDF supports many actions including for achieving lots of different results. For example there are JavaScript actions, URL actions, submit actions, actions to go to a page, actions to show/hide fields, actions to open files and more. These actions can be used to perform tasks in many places such as in outlines, links, buttons or in any Document, Page or Form Field Reader Events.
URLAction
This action is used to link to a web URL destination. The example below demonstrates how to create a link that would navigate to a specific URL.
[Java]
UrlAction action = new UrlAction("http://www.mydomain.com");
Link link = new Link(50, 50, Font.getHelvetica().getTextWidth("My Domain", 18), 20, action);
SubmitAction
This action sends the data in form fields to a specified URL. The example below demonstrates how to use a button to post form field data to a URL.
[Java]
SubmitAction submitAction = new SubmitAction("www.mydomain.com", FormExportFormat.HTML_POST);
Button button = new Button("btn", 50, 300, 100, 50);
button.setLabel("Submit");
button.setAction(submitAction);
GoToAction
This action is used to move to a particular page on the PDF document. The example below demonstrates how to use a button to navigate to a specific page.
[Java]
Button button = new Button("btn", 50, 150, 100, 30);
button.setLabel("Click Here");
GoToAction action = new GoToAction(2, PageZoom.FIT_WIDTH);
button.getReaderEvents().setMouseUp(action);
AnnotationShowHideAction
This action can be used to show/hide a specific form field. The example below demonstrates how to hide a form field using a button.
[Java]
Button button = new Button("btn", 50, 150, 100, 30);
button.setLabel("Click Here");
com.cete.dynamicpdf.pageelements.forms.TextField field = new com.cete.dynamicpdf.pageelements.forms.TextField("Text1", 330, 100, 100, 30);
field.setDefaultValue("Text Field Value");
AnnotationShowHideAction action = new AnnotationShowHideAction("Text1");
button.getReaderEvents().setMouseDown(action);
FileOpenAction
This action can be used to open a file, provided a native application to open that specific file is already installed. The example below demonstrates how to open a file using a button click.
[Java]
Button button = new Button("btn", 50, 150, 100, 30);
button.setLabel("Click Here");
FileOpenAction action = new FileOpenAction("Path of the file to open", FileLaunchMode.NewWindow);
button.getReaderEvents().setMouseUp(action);
ImportFormDataAction
This action can be used to fill the form fields by importing data from a FDF file. The example below demonstrates how to import a FDF file with a button click.
[Java]
Button button = new Button("btn", 50, 150, 100, 30);
button.setLabel("Click Here");
ImportFormDataAction action = new ImportFormDataAction("FdfFilePath");
button.getReaderEvents().setMouseUp(action);
ResetAction
This action resets all form field values to their default values.
[Java]
ResetAction action = new ResetAction();
Button button = new Button("btn", 50, 300, 100, 50);
button.setLabel("Reset");
button.getReaderEvents().setMouseEnter(action);
JavaScriptAction
DynamicPDF allows you to specify JavaScript code at the document level as well as at the form field level for any PDF. See the JavaScript topic for more information.