Actions

DynamicPDF Core Suite supports many actions derived from the Action class for achieving many different results. For example, DynamicPDF supports JavaScript actions, URL actions, submit actions, page navigation actions, actions to show/hide fields, actions to open files, and many more actions. Use these actions to perform tasks in many places, such as outlines, links, buttons, or any Document, Page, or FormField Reader Events. Examples illustrating the following actions are provided below.

All actions are inherited from the Action class; therefore, all examples could be substituted for a different concrete action.

URLAction

The URLAction supports linking to a web URL destination. After creating a URLAction instance, you can use it with any element possessing an action property. You pass a URLAction instance to a Link class constructor in this example. The Link class has a constructor that takes the coordinates to place the link and the action to perform as parameters. The following example demonstrates creating a Link that navigates to the created UrlAction instance.

UrlAction action = new UrlAction("http://www.mydomain.com");
Link link = new Link(50, 50, Font.Helvetica.GetTextWidth("My Domain", 18), 20, action);   
Dim MyAction As UrlAction = New UrlAction("http://www.mydomain.com")
Dim MyLink As Link = New Link(50, 50, Font.Helvetica.GetTextWidth("My Domain", 18), 20, MyAction)  

SubmitAction

The SubmitAction sends form field data to a specified URL. For example, the following code demonstrates how to use a button to post form field data to a URL.

SubmitAction submitAction = new SubmitAction("www.mydomain.com", FormExportFormat.HtmlPost);
Button button = new Button("btn", 50, 300, 100, 50);
button.Label = "Submit";
button.Action = submitAction;        
Dim MySubmitAction As SubmitAction = New SubmitAction("www.mydomain.com", FormExportFormat.HtmlPost)
Dim MyButton As Button = New Button("btn", 50, 300, 100, 50)
MyButton.Label = "Submit"
MyButton.Action = MySubmitAction 

GoToAction

The GoToAction moves to a particular page on a PDF document. The following example illustrates using a button to navigate to a specific page.

Button button = new Button("btn", 50, 150, 100, 30);
button.Label = "Click Here";
GoToAction action = new GoToAction(2, PageZoom.FitWidth);
button.ReaderEvents.MouseUp = action;        
Dim MyButton As Button = New Button("btn", 50, 150, 100, 30)
MyButton.Label = "Click Here"
Dim MyAction As GoToAction = New GoToAction(2, PageZoom.FitWidth)
MyButton.ReaderEvents.MouseUp = MyAction   

AnnotationShowHideAction

The AnnotationShowHideAction shows/hides a specific form field. The following example illustrates how to use a button to hide a form field.

Button button = new Button("btn", 50, 150, 100, 30);
button.Label = "Click Here";
ceTe.DynamicPDF.PageElements.Forms.TextField field = new ceTe.DynamicPDF.PageElements.Forms.TextField("Text1", 330, 100, 100, 30);
field.DefaultValue = "Text Field Value"; 
AnnotationShowHideAction action = new AnnotationShowHideAction("Text1");
button.ReaderEvents.MouseDown = action;        
Dim MyButton As Button = New Button("btn", 50, 150, 100, 30)
MyButton.Label = "Click Here"
Dim Myfield As ceTe.DynamicPDF.PageElements.Forms.TextField = New ceTe.DynamicPDF.PageElements.Forms.TextField("Text1", 330, 100, 100, 30)
Myfield.DefaultValue = "Text Field Value"
Dim MyAction As AnnotationShowHideAction = New AnnotationShowHideAction("Text1")
MyButton.ReaderEvents.MouseDown = MyAction 

FileOpenAction

The FileOpenAction opens a file, provided a native application to open that specific file is already installed. The following example demonstrates how to open a file using a button click (MouseUp).

Button button = new Button("btn", 50, 150, 100, 30);
button.Label = "Click Here";
FileOpenAction action = new FileOpenAction(@"Path of the file to open", FileLaunchMode.NewWindow);
button.ReaderEvents.MouseUp = action        
Dim MyButton As Button = New Button("btn", 50, 150, 100, 30)
MyButton.Label = "Click Here"
Dim MyAction As FileOpenAction = New FileOpenAction("Path of the file to open", FileLaunchMode.NewWindow)
MyButton.ReaderEvents.MouseUp = MyAction 

ImportFormDataAction

The ImportFormDataAction is used to fill form fields by importing data from a FDF file. The following example demonstrates how to import a FDF file with a button click (MouseUp).

Button button = new Button("btn", 50, 150, 100, 30);
button.Label = "Click Here";
ImportFormDataAction action = new ImportFormDataAction(@"FdfFilePath");
button.ReaderEvents.MouseUp = action;        
Dim MyButton As Button = New Button("btn", 50, 150, 100, 30)
MyButton.Label = "Click Here"
Dim MyAction As ImportFormDataAction = New ImportFormDataAction("FdfFilePath")
MyButton.ReaderEvents.MouseUp = MyAction  

ResetAction

The ResetAction resets all form field values to their default values. The following example illustrates.

ResetAction action = new ResetAction();
Button button = new Button("btn", 50, 300, 100, 50);
button.Label = "Reset";
button.ReaderEvents.MouseEnter = action;        
Dim MyAction As ResetAction = New ResetAction()
Dim MyButton As Button = New Button("btn", 50, 300, 100, 50)
MyButton.Label = "Reset"
MyButton.ReaderEvents.MouseEnter = MyAction 

JavaScriptAction

The JavaScriptAction is implemented differently than the previous example actions; DynamicPDF Core Suite allows specifying JavaScript code at the document level and the form field level for any PDF.

See the JavaScript topic for more information.

In this topic