Other PDF Issues

Automatically Display the Total PDF Page Count in Adobe Acrobat

Camila MilosovichCamila Milosovich Nov 19, 2026 868 views

Question details

Display the total number of pages automatically at the top of a PDF form while retaining page numbers at the bottom.

Automatically Display the Total PDF Page Count in Adobe Acrobat
Product
Adobe Acrobat or Adobe LiveCycle Designer
Device & OS
not provided
Scenario
A PDF form needs a total page count in a top-of-page field alongside existing footer page numbers.
Observed behavior
The form should show the current total page count and update it when pages are added or removed.
Before you start

Check whether the PDF is a standard Acrobat form or a dynamic LiveCycle/XFA form, because they use different scripting models. For an Acrobat form, you need a version of Acrobat that can edit form fields and document JavaScript.

Solution 1Recommended

Add an automatic page count field in Adobe Acrobat

Use this method for a standard Acrobat form to populate a text field whenever the PDF opens.

The script reads the document's page count and writes it to a named text field. It does not alter existing footer page numbers.

This method is for standard Acrobat forms, not dynamic LiveCycle/XFA forms. JavaScript must be enabled in the PDF viewer.

1
Add a text field

Open the PDF in Acrobat and choose All tools > Prepare a form. Add a text field at the top of the page and name it TotalPages.

2
Protect the field

Open the TotalPages field's Properties and select Read Only on the General tab so users do not accidentally change the displayed value.

3
Add the document script

Open Acrobat's JavaScript tools and choose Document JavaScripts. Add a script named UpdateTotalPages with this code: var field = this.getField("TotalPages"); if (field) field.value = this.numPages;

4
Save and test

Save the PDF, close it, and reopen it in Acrobat. Confirm that the top field shows the total and that the existing footer page numbers remain visible.

5
Refresh after page changes

After adding or removing pages using Acrobat's Organize pages tool, save, close, and reopen the PDF so the document script runs again.

Add an automatic page count field in Adobe Acrobat
Field placement: A field placed on one page appears only in that location. To display the total on additional pages, add appropriately named fields there and update the script to populate each field.
Free Microsoft Office alternative

View and work with PDF documents in WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface for working with PDFs and Office files. Its format compatibility makes it easy to move existing documents into your workflow. It does not replace Acrobat's document JavaScript for automatically populating this form field.

Open PDF documents and check their page countsCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar interface for working with documents and spreadsheetsFree, lightweight alternative for everyday Office tasks
microsoft office alternative - wps office

Frequently Asked Questions

Will the total update immediately when I add or remove a page?

The document script in this solution runs when the PDF opens. After changing pages in Organize pages, save, close, and reopen the PDF to refresh the field.

Will adding the total page count remove my footer page numbers?

No. Adding the TotalPages form field and document script does not change existing footer page numbers. Check the footer after saving and reopening the PDF.

Why is the total page count field blank?

Check that the field is named TotalPages in Prepare a form, that the document script was saved, and that JavaScript is enabled in the PDF viewer. Then close and reopen the PDF.

Can I use the same script in a dynamic LiveCycle form?

Not necessarily. Dynamic LiveCycle/XFA forms use a different scripting model and can paginate as their layout changes. Use LiveCycle Designer's layout and scripting features for those forms rather than relying on the standard Acrobat form script.