New to Telerik Document Processing? Start a free 30-day trial
JavaScript Actions
Updated on Jun 3, 2026
| Minimum Version | Q4 2024 |
|---|
RadPdfProcessing supports:
- JavaScript actions associated with documents, pages, form fields, and other elements.
- Event-triggered actions that execute after a certain event in the respective viewer (for example, RadPdfViewer, Adobe Acrobat, or a web browser) is triggered.
The JavaScriptAction class represents JavaScript actions and stores the JS content as plain text in its public Script property.

You can add JS actions by using the public Actions property of the following classes:
| Class | Collection Type |
|---|---|
Link* | ActionCollection |
BookmarkItem* | ActionCollection |
Widget | WidgetActionCollection |
FormField | FormFieldActionCollection |
RadFixedDocument | DocumentActionCollection |
RadFixedPage | PageActionCollection |
* The existing Action property is obsolete.
Adding a JavaScript Action to a TextBoxField
The following example demonstrates how to create a PDF document with three TextBoxField instances where the third field calculates the sum of the values entered in the first two widgets:

C#
RadFixedDocument document = new RadFixedDocument();
document.Pages.AddPage();
TextBoxField field1 = new TextBoxField("Field1");
VariableContentWidget widget1 = field1.Widgets.AddWidget();
widget1.Rect = new Rect(0, 0, 150, 30);
TextBoxField field2 = new TextBoxField("Field2");
VariableContentWidget widget2 = field2.Widgets.AddWidget();
widget2.Rect = new Rect(0, 50, 150, 30);
TextBoxField totalField = new TextBoxField("Total");
totalField.IsReadOnly = true;
totalField.Actions.Calculate = new Telerik.Windows.Documents.Fixed.Model.Actions.JavaScriptAction
("AFSimple_Calculate(\"SUM\", new Array (\"Field1\", \"Field2\"));");
VariableContentWidget totalWidget = totalField.Widgets.AddWidget();
totalWidget.Rect = new Rect(0, 100, 150, 30);
document.AcroForm.FormFields.Add(field1);
document.AcroForm.FormFields.Add(field2);
document.AcroForm.FormFields.Add(totalField);
document.Pages[0].Annotations.Add(widget1);
document.Pages[0].Annotations.Add(widget2);
document.Pages[0].Annotations.Add(totalWidget);
Using the MergedJavaScriptNameResolving Event
The MergedJavaScriptNameResolving event fires when resolving conflicts between JavaScript names while merging RadFixedDocument instances.
C#
document.MergedJavaScriptNameResolving += (sender, e) =>
{
if (e.UsedNames.Contains(e.Name))
{
e.NewName = e.Name + "1";
}
};