How to Create an Incrementing PDF Form Counter in Adobe Acrobat
Question details
The user needs to add a counter field to a PDF form that automatically increases its value (e.g., 0000001, 0000002) each time the document is opened from a shared network drive.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating an automatic sequential counter for a shared PDF form to track how many times it has been opened or to generate unique form IDs.
- Observed behavior
- The user requires a specific JavaScript setup to increment a text field's value upon opening the file, while considering limitations related to network sharing and file saving.
Ensure your PDF document contains a dedicated text field (e.g., named 'Counter') before attempting to add the JavaScript code.
Use Document JavaScript to Increment the Counter
Add a simple JavaScript code that triggers when the document opens, locating the target field and adding 1 to its current numeric value.
This method uses Adobe Acrobat's built-in JavaScript engine. However, the new counter value will not be retained if the user closes the PDF without saving.
Additionally, if the file is stored on a shared network drive, simultaneous access may cause it to open as 'read-only' for subsequent users, preventing the counter from saving correctly for everyone.
Open your PDF in Adobe Acrobat. Go to the 'Tools' menu, select 'JavaScript', and then click on 'Document JavaScripts'.
Create a new script and enter the following code: this.getField("Counter").value = Number(this.getField("Counter").value)+1; (Replace 'Counter' with the actual name of your text field if it differs).
Save and close the PDF document. The next time the file is opened, the script will automatically execute and increase the field's value by one.

Easily Manage and Edit PDF Forms with WPS PDF
While complex JavaScript counters require specific Adobe environments, WPS Office offers a highly compatible, intuitive platform for creating, filling, and editing PDF forms effortlessly.
- 1. Open WPS PDF: Launch WPS Office and open your PDF document using the built-in WPS PDF tool.
- 2. Access Form Tools: Navigate to the 'Form' tab to interact with text fields, checkboxes, and drop-down menus within your document.
- 3. Save and Share: Fill out the required form information and save your PDF locally or to a shared drive for your team to access.

Frequently Asked Questions
Why didn't the PDF counter update after I closed the file?
The counter script changes the field value when the file opens, but you must manually save the document before closing it. If you close the PDF without saving, the incremented value is lost.
Can multiple users update the counter simultaneously on a shared drive?
No. When the first user opens the file from a shared network drive, it typically becomes locked. Subsequent users will open it in read-only mode, meaning their individual counter updates cannot be saved back to the original file.
How do I format the counter to show leading zeros (e.g., 0000001)?
To display leading zeros, you will need to modify the JavaScript to format the numeric value as a string and pad it with zeros. This usually involves utilizing the util.printf('%07d', numericValue) function within your Document JavaScript.




