PDF Editing Issues

Create an Acrobat Pro Button to Convert Feet and Inches to Inches

Kushani NimanthikaKushani Nimanthika Nov 18, 2026 868 views

Question details

Create a PDF button that collects feet and inches in a dialog and displays the total number of inches.

Create an Acrobat Pro Button to Convert Feet and Inches to Inches
Product
Adobe Acrobat Pro
Device & OS
not provided
Scenario
The user wants a custom Acrobat JavaScript button to perform a measurement conversion in a PDF form.
Observed behavior
The desired result is an output field containing the total inches calculated from the dialog inputs.
Before you start

Open the PDF in Acrobat Pro and confirm that you can edit its form fields using Prepare a Form. Acrobat JavaScript must be enabled for the button action to run.

Solution 1Recommended

Add an Acrobat JavaScript dialog to a PDF button

Use a custom dialog to collect both measurements and write the converted value to a PDF text field.

The conversion formula is total inches = (feet × 12) + inches. The following example uses an output field named TotalInches.

1
Create the output field

In Acrobat Pro, open All tools > Prepare a form. Add a text field and name it TotalInches in its properties.

2
Add a button action

In Prepare a form, add a button and open its Properties. On the Actions tab, choose Mouse Up as the trigger and Run a JavaScript as the action, then select Add.

3
Enter the conversion script

In the JavaScript editor, paste the following code and save the action: var output = this.getField("TotalInches"); if (!output) { app.alert("Create a text field named TotalInches first."); } else { var conversionDialog = { initialize: function (dialog) { dialog.load({feet: "", inch: ""}); }, commit: function (dialog) { var values = dialog.store(); this.feet = values.feet; this.inches = values.inch; }, description: { name: "Convert to Inches", elements: [{ type: "view", elements: [ {type: "static_text", name: "Feet:"}, {type: "edit_text", item_id: "feet", width: 120}, {type: "static_text", name: "Inches:"}, {type: "edit_text", item_id: "inch", width: 120}, {type: "ok_cancel"} ] }] } }; if (app.execDialog(conversionDialog) == "ok") { var feetText = String(conversionDialog.feet).replace(/^\s+|\s+$/g, ""); var inchesText = String(conversionDialog.inches).replace(/^\s+|\s+$/g, ""); var feet = Number(feetText); var inches = Number(inchesText); if (feetText === "" || inchesText === "" || !isFinite(feet) || !isFinite(inches)) { app.alert("Enter a valid number in both fields."); } else { output.value = (feet * 12) + inches; } } }

4
Test the button

Close form editing or select Preview, click the button, enter values in both dialog fields, and select OK. For example, 5 feet and 6 inches should produce 66 in TotalInches.

Add an Acrobat JavaScript dialog to a PDF button
Viewer support: Custom Acrobat JavaScript dialogs may not work in every PDF viewer. Test the saved form in the Acrobat viewer your recipients will use.
Free Microsoft Office alternative

Work with PDF and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDF and Microsoft Office files. Its Office format compatibility makes it easy to bring existing documents into your workflow. The Acrobat JavaScript button in this guide still requires a compatible PDF viewer.

Open and review PDFs alongside your other documentsCompatible with Microsoft Word, Excel, and PowerPoint formatsUse a familiar interface to work with existing Office filesKeep document, spreadsheet, presentation, and PDF tools in one lightweight suite
microsoft office alternative - wps office

Frequently Asked Questions

What formula converts feet and inches to inches?

Multiply the feet value by 12 and add the inches value. For example, (5 × 12) + 6 equals 66 inches.

Where do I add JavaScript to an Acrobat button?

Open All tools > Prepare a form, open the button's Properties, and use the Actions tab to add a Mouse Up action with Run a JavaScript.

Why does the script say the output field is missing?

The example looks for a text field named TotalInches. Check the field name in Prepare a form, or change the name in this.getField("TotalInches") to match your field.

Will the dialog work in every PDF viewer?

No. PDF viewers differ in their support for Acrobat JavaScript and custom dialogs. Test the button in the intended viewer before distributing the form.