How to Calculate Gestational Age and Due Date in Adobe Acrobat Forms
Question details
The user needs to configure a PDF form to automatically calculate a pregnancy due date by adding 280 days to an entered Last Menstrual Period (LMP) date.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Designing a healthcare or medical PDF form where an estimated due date must be automatically generated based on patient input.
- Observed behavior
- The form requires a custom calculation script to correctly parse an inputted date, perform the 280-day mathematical addition, and format the output as a valid date string.
Ensure you have Adobe Acrobat Pro or a professional PDF editor with form creation and JavaScript support installed, as standard PDF readers cannot create or edit custom calculation scripts.
Use a Custom Calculation Script in Adobe Acrobat
Add a custom JavaScript code to the result field to parse the input date, mathematically add 280 days, and format the output as a date.
PDF forms use JavaScript for advanced date calculations. You will need to create two text fields: one for the reference date (LMP) and one for the calculated result (Due Date). Acrobat's built-in date formatting tools will ensure the final output is readable.
Open your PDF in Prepare Form mode. Add two text fields. Name the first field 'LMP' (for Last Menstrual Period) and the second field 'DueDate'. Ensure both fields are set up correctly.
Right-click the 'LMP' field and select Properties. Go to the Format tab, choose 'Date' from the Select format category, and pick a standard format like 'mm/dd/yyyy'. Repeat this exact formatting step for the 'DueDate' field.
Right-click the 'DueDate' field and open Properties. Navigate to the Calculate tab, select 'Custom calculation script', and click the Edit button.
In the JavaScript editor, define a variable to retrieve the LMP date using this.getField('LMP').value. Use Acrobat's util.scand function to parse it, add 280 days using standard Date object math (multiplying by 24 hours, 60 minutes, 60 seconds, and 1000 milliseconds), and output the result using util.printd.

Create and Manage Interactive PDF Forms with WPS PDF
If you need an efficient way to handle digital documents, WPS Office provides a comprehensive PDF editor. It allows you to create interactive forms, add text fields, and smoothly manage your document workflows without a steep learning curve.
- 1. Open WPS PDF: Launch WPS Office and switch to the PDF module to open your document.
- 2. Navigate to the Form tab: Click on the 'Form' tab in the top ribbon to access all interactive form creation tools.
- 3. Add form fields: Select 'Text Field' or 'Date Field' from the toolbar and click on the page to place them where you need user input.
- 4. Save and distribute: Adjust the properties as needed, then save the document as a standard PDF to share with patients or clients.

Frequently Asked Questions
Can I use this calculation script in free PDF readers?
Most modern free PDF readers can successfully execute the JavaScript to calculate the due date when a user is filling out the form. However, to actually create the form fields and insert the JavaScript code, you must use a professional PDF editor like Adobe Acrobat Pro.
Why is my PDF date calculation showing an error or invalid date?
This typically occurs if the input date format entered by the user does not exactly match the format expected by the util.scand function in your script. Ensure both the field's Format properties and your JavaScript code use identical date string formats (e.g., 'mm/dd/yyyy').
How many days should be added for a standard gestational age calculation?
Standard medical calculations estimate a pregnancy due date by adding exactly 280 days (which is equivalent to 40 weeks) to the first day of the patient's last menstrual period (LMP).




