PDF Editing Issues

How to Calculate Dates and Convert Numbers to Words in PDF Forms

Chanuka GeekiyanageChanuka Geekiyanage Nov 3, 2026 869 views

Question details

The user needs to automate form fields by adding days to an existing date and converting a numeric value into spelled-out words using JavaScript.

How to Calculate Dates and Convert Numbers to Words in PDF Forms
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Designing an interactive PDF document, such as an invoice or contract, where due dates calculate automatically and monetary amounts must be spelled out in text.
Observed behavior
Standard PDF form properties lack native built-in functions to convert numbers to words or calculate dynamic dates, requiring the implementation of document-level and field-level JavaScript.
Before you start

Ensure you have an advanced PDF editor with interactive form and JavaScript support, and verify that the target form fields are correctly named before applying any calculation scripts.

Solution 1Recommended

Calculate a Future Date by Adding Days

Use the Acrobat JavaScript API to parse the starting date, add the required days, and format the output dynamically.

To calculate a new date, you must retrieve the initial date string, convert it into a JavaScript Date object using the util.scand method, add the numerical value in milliseconds, and format it back into a readable date using util.printd.

1
Access Field Properties

Open your PDF form in editing mode, right-click the destination date field, and select 'Properties'.

2
Enable Custom Calculation

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

3
Parse the Source Date

Write a script to retrieve the value from the source date field and use util.scand('mm/dd/yyyy', sourceValue) to parse it into a date object.

4
Calculate and Output

Convert your target days into milliseconds, add them to the parsed date object's current time, and use util.printd('mm/dd/yyyy', newDateObject) to display the calculated result.

Calculate a Future Date by Adding Days
Input Validation: Always validate the source field to ensure it is not empty, invalid, or out-of-range before executing the calculation to prevent console errors.
Advanced PDF Form Editing

Create and Manage Interactive PDF Forms with WPS Office

WPS Office provides robust PDF editing capabilities, enabling you to design interactive forms, add customizable fields, and configure automated calculations effortlessly.

  1. 1. Open the PDF Editor: Launch WPS Office and open your document using the PDF editing module.
  2. 2. Navigate to the Form Tab: Click on the 'Form' tab on the top ribbon to access interactive form controls.
  3. 3. Insert Form Fields: Select the text or date field tools and draw them directly onto your document.
  4. 4. Configure Properties: Double-click the inserted field to open its properties menu and adjust formatting or calculate settings.
  5. 5. Save the Document: Save your PDF document to finalize the interactive form layout and logic.
Easily insert text, number, and date form fields.Supports interactive form properties and basic JavaScript logic.Fully compatible with standard Adobe Acrobat PDF form formats.Lightweight alternative with an intuitive user interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my PDF date calculation returning an error or showing blank?

This generally happens if the source date field is completely empty or improperly formatted. Make sure your JavaScript explicitly checks if the source field is blank before attempting to parse the date with util.scand.

Is there a built-in format to automatically spell out numbers in PDF forms?

No, standard PDF editors do not possess a built-in formatting option to convert numeric values to words. You must insert a custom document-level JavaScript function to manage this conversion dynamically.

Can I use standard JavaScript Date methods instead of util.scand?

While standard JavaScript Date objects are partially supported, utilizing the Acrobat-specific API methods like util.scand and util.printd is highly recommended. These methods are tailored to accurately process date formats according to the viewer's specific localization settings.