How to Create Bates-Style Numbering with JavaScript in Adobe Acrobat
Question details
The user wants to automate Bates-style numbering in PDF documents using JavaScript in Adobe Acrobat.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Automating sequential document numbering using custom scripts.
- Observed behavior
- Acrobat does not provide a direct JavaScript API to invoke the native Bates numbering feature, requiring a workaround using text watermarks.
Ensure you have Adobe Acrobat Pro installed, as the standard version or free Reader may have limited execution privileges for adding advanced JavaScript watermarks.
Use JavaScript Watermarks as a Bates Numbering Alternative
Since native Bates numbering isn't exposed to JavaScript, you can use the addWatermarkFromText method to simulate sequential Bates-style stamping.
Adobe Acrobat does not offer a direct JavaScript interface for its native Bates Numbering command. However, you can achieve a nearly identical visual result by programmatically adding a text watermark to your PDF pages.
This approach not only simulates Bates numbering but also provides extensive customization, allowing you to automatically include dynamic data such as the current file name within the numbering sequence.
Launch Adobe Acrobat Pro, open your PDF document, and press Ctrl+J (Windows) or Cmd+J (Mac) to open the JavaScript Debugger Console.
Write a custom script that utilizes the 'this.addWatermarkFromText()' method to generate the text overlay.
Within your script, configure the sequential numbering string, font size, color, and location coordinates to match typical Bates numbering placements (usually headers or footers).
Run the script to apply the numbers. The sequence will be added to the document's 'Watermark' layer rather than the hidden 'Headers and Footers' layer used by the native tool.

Add Bates Numbering Easily with WPS PDF
Instead of writing complex JavaScript code to simulate Bates numbering in Adobe Acrobat, you can use the built-in, user-friendly Bates Numbering feature in WPS Office to instantly format and apply sequential numbers to your legal or business documents.
- 1. Open your PDF in WPS Office: Launch WPS PDF and open the document you need to number.
- 2. Access Bates Numbering: Navigate to the 'Protect' or 'Page' tab on the top ribbon and select 'Bates Numbering'.
- 3. Configure the Sequence: Click 'Add' to open the configuration dialog. Set your desired prefix, starting number, font style, and page position.
- 4. Apply and Save: Click 'OK' to instantly apply the native Bates numbering to your document, then save the file.

Frequently Asked Questions
Can I access the native Adobe Acrobat Bates numbering tool using JavaScript?
No, Adobe Acrobat does not expose an API or JavaScript interface for its built-in Bates numbering command. The standard programmatic workaround is to use the addWatermarkFromText method instead.
How do JavaScript watermarks compare to native Bates numbering?
While visually identical when formatted correctly, they differ structurally. Native Bates numbering utilizes a hidden 'Headers and Footers' layer, whereas the JavaScript approach places the sequential text under the 'Watermark' layer.
Can I add the document filename to the Bates number using JavaScript?
Yes. One major advantage of writing a custom JavaScript watermark is that you have full control over the output text string, allowing you to dynamically fetch and append the document's file name to the Bates number sequence.




