PDF Editing Issues

How to Stop Acrobat PDF Age Calculation from Rounding Up

Anum MushtaqAnum Mushtaq Oct 28, 2026 868 views

Question details

The user needs to prevent an Acrobat PDF form age calculation from rounding up, aiming to truncate the result so the age displays as a whole number without rounding to the next year.

How to Stop an Acrobat Age Calculation from Rounding Up
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating or editing a PDF form that includes an automated age calculation based on a date of birth.
Observed behavior
The age calculation script rounds the result up to the next number (e.g., 25.6 becomes 26) instead of truncating it to the actual completed age (25).
Before you start

Ensure you have access to edit the PDF form fields and can view the custom JavaScript code currently applied to your age calculation field.

Solution 1Recommended

Modify Custom JavaScript to Truncate the Age

Adjust the calculation script using JavaScript's Math.floor() function to ensure the age is always rounded down to the nearest whole number.

When calculating age in PDF forms, simply dividing the days by 365.25 can yield decimals. If the script uses Math.round(), a person who is 25.6 years old will incorrectly show as 26. Using Math.floor() forces the decimal to truncate, showing the correct completed age of 25.

1
Enter Prepare Form Mode

Open your PDF form in Acrobat, go to the Tools menu, and select 'Prepare Form' to enable field editing.

2
Open Field Properties

Right-click the text field where the age calculation is displayed and select 'Properties' from the context menu.

3
Edit the Calculation Script

Navigate to the 'Calculate' tab, select 'Custom calculation script', and click the 'Edit' button to view your current JavaScript.

4
Apply Math.floor()

Locate the final calculation line in your script and wrap the result in Math.floor(). For example, change it to: event.value = Math.floor(calculatedAge);

5
Save and Test

Click 'OK' to save the script, close the Properties dialog, and preview the form to test the calculation with sample dates.

Modify Custom JavaScript to Truncate the Age
Script Successfully Updated: Using Math.floor() guarantees the age will always represent the number of full years passed without premature rounding.
Advanced PDF Form Editing

Create and Edit PDF Forms with WPS Office

WPS Office features a comprehensive PDF editor that allows you to easily fill, create, and manage PDF forms. Enjoy a complete office suite for documents, spreadsheets, presentations, and PDFs in one lightweight application.

  1. 1. Download WPS Office: Download and install WPS Office from the official website.
  2. 2. Open Your PDF: Launch WPS Office and open your PDF file using the built-in WPS PDF tool.
  3. 3. Manage Form Fields: Navigate to the Form tab to add, edit, or manage interactive form fields effortlessly.
  4. 4. Save and Export: Save your changes and export your interactive PDF form securely.
Supports creating and editing interactive PDF formsFully compatible with standard Adobe PDF document formatsLightweight and runs smoothly on Windows, Mac, and mobile devicesAll-in-one suite for Word, Excel, PPT, and PDF editing
QA img-9

Frequently Asked Questions

Why does my PDF age calculation show decimals?

If your calculation script divides total days by 365.25 without applying a formatting function like Math.floor() or Math.round(), the result will display the exact decimal value.

What is the difference between Math.round and Math.floor in PDF JavaScript?

Math.round() rounds the number to the nearest integer (e.g., 25.6 becomes 26), whereas Math.floor() always rounds down to the nearest integer, which is standard for calculating a person's completed age (e.g., 25.6 stays 25).

Can I do age calculations without JavaScript in Acrobat?

No, calculating the exact age from a birthdate and a current date requires a custom calculation script to accurately parse the dates and compute the difference in years.

Where do I input the custom calculation script in a PDF form?

You can input custom scripts by opening the form field's Properties, navigating to the Calculate tab, selecting 'Custom calculation script', and clicking the Edit button.