PDF Editing Issues

Number Odd PDF Pages Consecutively in Adobe Acrobat with JavaScript

Phi Hung VoPhi Hung Vo Nov 19, 2026 868 views

Question details

Add consecutive visible numbers only to odd-numbered PDF pages using Adobe Acrobat JavaScript.

Number Odd PDF Pages Consecutively in Adobe Acrobat with 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.
Before you start

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.

Solution 1Recommended

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.

1
Enable JavaScript

In Acrobat, open Preferences > JavaScript and ensure Acrobat JavaScript is enabled.

2
Open the console

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.

3
Run the script

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++; }

4
Check and save

Inspect pages 1, 3, and 5 to confirm the numbers and placement, then choose File > Save As to save the numbered PDF.

Avoid duplicate numbers: Running the script again adds another set of watermarks. Test on a copy first, and adjust the font, size, or vertical offset in the script before applying it to the final document.
Free Microsoft Office alternative

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.

Open and review PDF pages in WPS OfficeCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar interface for working with existing Office filesFree and lightweight software for everyday document tasks
microsoft office alternative - wps office

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.