PDF Editing Issues

How to Create Consecutive Invoice Numbers in Adobe Acrobat PDF Forms

Aamir Naveed AkramAamir Naveed Akram Oct 28, 2026 869 views

Question details

The user needs to automatically generate unique, consecutive invoice numbers within a fillable PDF form.

How to Create Consecutive Invoice Numbers in an Acrobat Form
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Setting up a dynamic PDF invoice template that automatically assigns the next sequential number upon a specific user action, such as saving or clicking a button.
Observed behavior
The user wants to transition from manually typing invoice numbers to using an automated script that increments numbers sequentially while preventing regeneration on previously finalized documents.
Before you start

Ensure you have Adobe Acrobat Pro installed, as the free Reader version cannot create or edit form fields. Familiarize yourself with the 'Prepare Form' tool and basic JavaScript implementation in Acrobat.

Solution 1Recommended

Use a Custom JavaScript Action to Auto-Increment Numbers

Create a read-only text field and attach a custom JavaScript code to a specific trigger event (like a button click) to generate the next invoice number.

To successfully automate invoice numbering, you must first define the exact trigger for generation (e.g., when a 'Generate Invoice' button is clicked). The JavaScript will check if a number already exists, pull the baseline number, increment it, and lock the field so the number is not overwritten if the document is reopened later.

1
Create the invoice number text field

Open your PDF template in Acrobat and select 'Tools' > 'Prepare Form'. Add a new Text Field and name it 'InvoiceNumber'. In the field properties, check the 'Read Only' box so users cannot manually edit the generated number.

2
Set up the generation trigger

Decide how the number will be triggered. For a manual trigger, add a 'Button' form field and label it 'Generate Number'.

3
Add the JavaScript code

Right-click the button field and select 'Properties'. Navigate to the 'Actions' tab, select 'Mouse Up' as the trigger, choose 'Run a JavaScript' from the action dropdown, and click 'Add'.

4
Implement the increment logic

Enter your JavaScript code in the editor. The code should first verify if 'InvoiceNumber' is empty. If empty, it should retrieve the last global invoice number (using a folder-level script or global variable), add 1, display the new value in the text field, and update the global tracker.

Persistent Tracking Limitation: Standard document-level JavaScript resets when a new instance of the blank PDF is opened. To ensure consecutive numbering across entirely separate PDF files, you must utilize a folder-level JavaScript file (.js) saved in your Acrobat application folder to store and recall the global number variable.
Manage PDF Invoices Easily

Create and Edit PDF Forms with WPS Office

If you need an efficient way to handle PDF forms and invoices without complex coding, WPS Office provides intuitive PDF editing tools. You can easily insert text fields, design customized invoice templates, and manage your billing documents seamlessly.

  1. 1. Open WPS Office PDF: Launch WPS Office and navigate to the PDF tools section to open your existing invoice template or create a new one.
  2. 2. Access the Form Tools: Click on the 'Form' tab in the top ribbon to access interactive form elements like Text Fields, Checkboxes, and Push Buttons.
  3. 3. Insert Custom Fields: Click 'Text Field' and drag it onto your document where the invoice number or client details should go.
  4. 4. Adjust Field Properties: Double-click the inserted field to modify its properties, such as changing its name, setting a default value, or making it read-only.
  5. 5. Save the Template: Save your completed fillable PDF invoice to your local drive or WPS Cloud for future use.
Easily insert interactive text fields, checkboxes, and buttons into invoices.Fully compatible with standard Adobe PDF formats.Lightweight, fast alternative to resource-heavy PDF editors.Supports seamless cloud syncing to manage templates across all devices.
microsoft office alternative - wps office

Frequently Asked Questions

Can I generate consecutive invoice numbers without using JavaScript?

No, standard PDF forms do not include a native auto-incrementing feature. You must either use JavaScript within the PDF or use external spreadsheet software like Excel to handle sequential numbering.

Why does my invoice number reset every time I open the blank PDF template?

By default, local PDF files do not share data with each other. A newly opened blank template doesn't know the number used in the previously saved document unless you implement a folder-level JavaScript file to store a persistent global variable.

How can I prevent the invoice number from changing when I reopen a saved invoice?

Your JavaScript code should include a condition that checks if the invoice number field is already populated. If it contains a value, the script should bypass the generation step, leaving the existing number intact.

Is it easier to make consecutive invoices in a spreadsheet?

Yes, using spreadsheet software like WPS Spreadsheet or Excel is generally much easier for consecutive invoicing. Spreadsheets support simple drag-to-fill features and macros that manage sequential data much more natively than PDF forms.