PDF Editing Issues

How to Calculate a Due Date from a Submission Date in PDF Forms

Emma BrownEmma Brown Nov 10, 2026 869 views

Question details

The user needs to create an automated calculation in a PDF form that adds the number of days selected in an Invoice Terms drop-down to a Submission Date field to populate a Due Date field.

Calculate a Due Date from a Submission Date in PDF Forms
Product
PDF Form Editor
Device & OS
not provided
Scenario
Creating an interactive PDF invoice or form where the payment deadline dynamically updates based on the selected terms and the date submitted.
Observed behavior
The user requires a custom calculation script to fetch values from a date field and a drop-down field, perform a date addition, and return the formatted result into a third field.
Before you start

Ensure your PDF editor supports JavaScript for custom field calculations. Additionally, verify that your 'Invoice Terms' drop-down options are assigned numerical export values (e.g., '0' for Due on receipt, '30' for Net 30).

Solution 1Recommended

Apply a Custom Calculation JavaScript to the Due Date Field

Use a custom JavaScript to read the submission date, parse it, add the specified number of days from the drop-down, and output the new date to the Due Date field.

PDF forms use standard JavaScript to handle complex field interactions. The util.scand and util.printd functions are specifically used to parse string inputs into date objects and format them back into strings.

1
Open Field Properties

Open your PDF in form editing mode. Right-click the 'Due Date' text field and select 'Properties' from the context menu.

2
Select Custom Calculation

Navigate to the 'Calculate' tab in the Properties window. Choose the 'Custom calculation script' option and click the 'Edit' button.

3
Enter the JavaScript Code

Paste the following script into the editor: var terms = Number(this.getField('Invoice Terms Dropdown').valueAsString); var submission = this.getField('Submission Date').value; if (submission == '') { event.value = ''; } else { var date = util.scand('mm-dd-yyyy', submission); date.setDate(date.getDate() + terms); event.value = util.printd('mm-dd-yyyy', date); }

4
Configure Drop-down Values

Open the Properties for your 'Invoice Terms Dropdown' field. Under the 'Options' tab, ensure each item has an 'Export Value' that contains only the numeric number of days (e.g., '30').

Apply a Custom Calculation JavaScript to the Due Date Field
Match Field Names Exactly: JavaScript is case-sensitive. Ensure that the field names inside the getField('') functions exactly match the names of the fields in your PDF form, including spaces and capitalization. Also, adjust the 'mm-dd-yyyy' format strings if your form uses a different date format.
Efficient PDF Form Management

Create, Edit, and Manage PDF Forms with WPS PDF

WPS Office provides a comprehensive and easy-to-use PDF editing suite. You can effortlessly fill out interactive forms, edit text, insert dates, and manage your documents securely.

  1. 1. Download and Install: Download WPS Office for free and launch the application on your device.
  2. 2. Open the PDF File: Click on the 'PDF' tab and open your interactive invoice or form document.
  3. 3. Fill the Form Fields: Click directly on the interactive fields, such as drop-downs and text boxes, to input your data and dates.
  4. 4. Save and Export: Once your form is completely filled out, save the document or export it directly as a flat PDF to send to your clients securely.
Easily fill and manage interactive PDF forms, including invoices and contracts.Highly compatible with standard PDF formats and interactive elements from Adobe Acrobat.Lightweight, fast, and features a user-friendly tabbed interface for managing multiple PDFs.Comes integrated with Writer, Spreadsheet, and Presentation tools in one single application.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my calculated date returning an error or showing blank?

This usually happens if the date format in the script (e.g., 'mm-dd-yyyy') does not perfectly match the format of the date entered in the Submission Date field, or if the field names have a typo.

Can I use a text field instead of a drop-down for the Invoice Terms?

Yes. The same script will work with a text field instead of a drop-down, provided the user types a valid numerical value representing the number of days into the field.

How do I exclude weekends from the due date calculation?

The standard setDate() function adds continuous calendar days. Excluding weekends requires a more advanced JavaScript loop that checks the day of the week using date.getDay() and skips over Saturdays (6) and Sundays (0).

How do I correctly set up the drop-down list to output numbers?

In the drop-down field properties under the 'Options' tab, type your descriptive text (like 'Net 30') into the 'Item Name' box, and type the corresponding number ('30') into the 'Export Value' box. Then click 'Add'.