Number Odd PDF Pages Consecutively in Adobe Acrobat with JavaScript
Question details
Add consecutive visible numbers only to odd-numbered PDF pages using Adobe Acrobat JavaScript.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- The user wants physical pages 1, 3, 5, and so on to display consecutive numbers 1, 2, 3, and so on.
- Observed behavior
- Only odd physical pages should receive a number, and the numbering should increase without gaps.
Open the PDF in Adobe Acrobat and check that you can edit it and access the JavaScript console. The script counts physical pages from the beginning of the document, regardless of existing page labels.
Add consecutive numbers to odd pages with Acrobat JavaScript
Use a separate counter and text watermarks to number odd physical pages without gaps.
The script adds visible text to the page; it does not change the PDF's page labels. Page indexes in Acrobat JavaScript start at zero, so indexes 0, 2, and 4 correspond to physical pages 1, 3, and 5.
In Acrobat, open Preferences > JavaScript and ensure Acrobat JavaScript is enabled.
Open the PDF, then open the JavaScript console with Ctrl+J on Windows or Command+J on macOS. Console availability can depend on your Acrobat version and settings.
Paste the following into the console, select the entire script, and execute it with Ctrl+Enter on Windows, Command+Enter on macOS, or the numeric keypad Enter key: var number = 1; for (var i = 0; i < this.numPages; i += 2) { this.addWatermarkFromText({ cText: String(number), cFont: "Helvetica", nFontSize: 10, nHorizAlign: 1, nVertAlign: 2, nVertValue: 36, nStart: i, nEnd: i }); number++; }
Inspect pages 1, 3, and 5 to confirm the numbers and placement, then choose File > Save As to save the numbered PDF.
Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight, easy-to-use Office alternative with a familiar interface and support for common Microsoft Office formats, making it easy to move existing files into your workflow. Its PDF tools can help you review and edit documents, but they do not run the Acrobat-specific script above.

Frequently Asked Questions
Will the script number PDF pages 1, 3, and 5 as 1, 2, and 3?
Yes. It starts at physical page 1 and increments the displayed counter only after processing an odd physical page.
Does this change the page labels in Acrobat's navigation pane?
No. The script uses addWatermarkFromText to place visible numbers on the pages; it does not modify PDF page labels.
How can I change where the numbers appear?
Edit the alignment and offset values in the console script before running it. For example, adjust nVertValue to change the vertical position, then check the result on a copy.
Why can't I run the script in my PDF viewer?
The script uses Acrobat-specific JavaScript and requires access to Acrobat's JavaScript console and permission to modify the PDF. Check Preferences > JavaScript and the document's editing restrictions.




