New to Telerik Document Processing? Start a free 30-day trial
Multiplying TextBoxField Values with JavaScript Actions and RadPdfProcessing
Updated on Jun 9, 2026
Environment
| Version | Product | Author |
|---|---|---|
| Q4 2024 | RadPdfProcessing | Desislava Yordanova |
Description
This article shows how to create a PDF document with three TextBoxFields where the third field multiplies the values of the first two widgets.
Solution
Use the JavaScript Actions feature introduced in Q4 2024 for the RadPdfProcessing library:
Example 1: Multiply Two TextBoxField Values with a JavaScript Action
csharp
RadFixedDocument document = new RadFixedDocument();
document.Pages.AddPage();
TextBoxField priceField = new TextBoxField("Price");
priceField.Value = "12";
priceField.IsReadOnly = true;
VariableContentWidget priceWidget = priceField.Widgets.AddWidget();
priceWidget.Rect = new Rect(new Size(150, 30));
TextBoxField amountField = new TextBoxField("Amount");
VariableContentWidget amountWidget = amountField.Widgets.AddWidget();
amountWidget.Rect = new Rect(new Point(0, 50), new Size(150, 30));
TextBoxField totalField = new TextBoxField("Total");
totalField.IsReadOnly = true;
totalField.Actions.Calculate = new Telerik.Windows.Documents.Fixed.Model.Actions.JavaScriptAction
("AFSimple_Calculate(\"PRD\", new Array (\"Amount\", \"Price\"));");
VariableContentWidget totalWidget = totalField.Widgets.AddWidget();
totalWidget.Rect = new Rect(new Point(0, 100), new Size(150, 30));
document.AcroForm.FormFields.Add(priceField);
document.AcroForm.FormFields.Add(amountField);
document.AcroForm.FormFields.Add(totalField);
document.Pages[0].Annotations.Add(priceWidget);
document.Pages[0].Annotations.Add(amountWidget);
document.Pages[0].Annotations.Add(totalWidget);
The following image shows the result:
