Calculate a Mortgage Interest Rate in an Adobe Acrobat PDF Form
Question details
Determine the inputs and formula needed to calculate a mortgage interest rate in a PDF form using JavaScript.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A form creator wants a calculated PDF field to derive an interest rate from mortgage details.
- Observed behavior
- The form should calculate a rate from the supplied loan terms and display it in the intended periodic or annual convention.
Identify the loan amount, payment amount, payment frequency, and term, and decide whether the result should be a periodic, nominal annual, or effective annual rate. Confirm whether payments occur at the end of each period and whether a balance remains after the last payment.
Calculate the rate with an Acrobat form script
Use a custom calculation script when the loan has equal end-of-period payments and no final balance.
For a fully amortizing loan, the formula is loan amount = payment × [1 − (1 + r)^(−n)] / r, where r is the rate per payment period and n is the number of payments. At a zero rate, the loan amount equals payment × n. The rate generally must be found numerically.
The example below finds a nonnegative periodic rate up to 100% per period and displays the nominal annual rate as a number of percentage points. It excludes fees, insurance, extra payments, and any final balance.
In Acrobat, open the PDF and choose Prepare a form. Add number fields named LoanAmount, PaymentAmount, PaymentsPerYear, and TermYears. Enter the payment frequency as a number, such as 12 for monthly payments.
Add a text field for the rate, open its Properties, and select the Calculate tab. Choose Custom calculation script and click Edit.
Paste this script into the editor and save it: var loan = Number(this.getField('LoanAmount').value); var payment = Number(this.getField('PaymentAmount').value); var frequency = Number(this.getField('PaymentsPerYear').value); var years = Number(this.getField('TermYears').value); var n = frequency * years; event.value = ''; if (isFinite(loan) && isFinite(payment) && isFinite(frequency) && isFinite(years) && loan > 0 && payment > 0 && frequency > 0 && frequency % 1 === 0 && years > 0 && n > 0 && n % 1 === 0) { function presentValue(rate) { return rate === 0 ? payment * n : payment * (1 - Math.pow(1 + rate, -n)) / rate; } if (presentValue(0) >= loan && presentValue(1) <= loan) { var low = 0, high = 1; for (var i = 0; i < 100; i++) { var mid = (low + high) / 2; if (presentValue(mid) > loan) low = mid; else high = mid; } event.value = ((low + high) / 2 * frequency * 100).toFixed(2); } }
In the result field's Properties, use a number format and label the field as a nominal annual percentage rate. Preview the form, enter known loan values, and compare the result with a trusted loan calculator.

Calculate a mortgage rate with WPS Spreadsheet
Use the RATE function in WPS Spreadsheet to calculate a mortgage rate from the loan amount, payment, term, and payment frequency. This calculates the rate separately; it does not add an Acrobat JavaScript calculation to the PDF.
- 1. Open a spreadsheet: Open WPS Spreadsheet and create a blank workbook.
- 2. Enter the loan details: Enter the loan amount in B1, the positive payment amount in B2, the term in years in B3, and the number of payments per year in B4.
- 3. Calculate the annual rate: In B5, enter =RATE(B3*B4,-B2,B1)*B4 to calculate the nominal annual rate, assuming end-of-period payments and no final balance.
- 4. Format and verify: Select B5 and apply the Percentage number format. Compare the result with a known loan example to verify the inputs.

Frequently Asked Questions
What information is needed to calculate the interest rate?
You need the loan amount, payment amount, number of payments or loan term, and payment frequency. You also need to know when payments occur and whether a final balance remains.
Where do I add JavaScript to an Acrobat form field?
Open the PDF in Acrobat, choose Prepare a form, and open the result field's Properties. On the Calculate tab, select Custom calculation script and click Edit.
Why does the example leave the rate field blank?
Check the four input fields for positive numbers and a whole number of payments. The example also leaves the result blank if the rate would be negative or greater than 100% per payment period.
Is the nominal annual rate the same as the effective annual rate?
No. The nominal annual rate is the periodic rate multiplied by the number of periods per year. The effective annual rate accounts for compounding: (1 + periodic rate) raised to the number of periods per year, minus 1.
Can this calculation handle a final balloon payment?
Not as written. The example assumes a zero final balance. A balloon payment requires a formula that includes the remaining balance and a corresponding change to the script.




