PDF Editing Issues

How to Create Bates-Style Numbering with JavaScript in Adobe Acrobat

Algirdas JasaitisAlgirdas Jasaitis Nov 5, 2026 871 views

Question details

The user wants to automate Bates-style numbering in PDF documents using JavaScript in Adobe Acrobat.

How to Create Bates-Style Numbering 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.
Before you start

Ensure you have Adobe Acrobat Pro installed, as the standard version or free Reader may have limited execution privileges for adding advanced JavaScript watermarks.

Solution 1Recommended

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.

1
Access the JavaScript Console

Launch Adobe Acrobat Pro, open your PDF document, and press Ctrl+J (Windows) or Cmd+J (Mac) to open the JavaScript Debugger Console.

2
Prepare the Watermark Script

Write a custom script that utilizes the 'this.addWatermarkFromText()' method to generate the text overlay.

3
Define Text and Parameters

Within your script, configure the sequential numbering string, font size, color, and location coordinates to match typical Bates numbering placements (usually headers or footers).

4
Execute the Script

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.

Use JavaScript Watermarks as a Bates Numbering Alternative
Layer Differences: Native Bates numbering uses a hidden Headers and Footers layer. This JavaScript method visually replicates the effect but stores the text under the Watermark layer.
Easier PDF Management

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. 1. Open your PDF in WPS Office: Launch WPS PDF and open the document you need to number.
  2. 2. Access Bates Numbering: Navigate to the 'Protect' or 'Page' tab on the top ribbon and select 'Bates Numbering'.
  3. 3. Configure the Sequence: Click 'Add' to open the configuration dialog. Set your desired prefix, starting number, font style, and page position.
  4. 4. Apply and Save: Click 'OK' to instantly apply the native Bates numbering to your document, then save the file.
Visual Bates numbering interface without any coding requiredBatch process multiple PDF files simultaneouslyHighly compatible with standard Adobe PDF formatsLightweight, fast, and easy to use on any device
QA img-9

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.