Skip to main content
Participating Frequently
September 8, 2025
Question

Script for InDesign to skip "Ghosted" pages while automatically #-ing pages! (A/E/C community)

  • September 8, 2025
  • 5 replies
  • 534 views

I created a script for InDesign to skip "Ghosted" pages while continuing to automatically number pages in a document. We use this often in the Architectural, Engineering, and Construction industry to omit section tabs from the page count. I would like to share it with the A/E/C community, but do not know how to make it available beyond asking this forum. Does anyone know how to make this a readily availble resource or let Adobe InDesign know so that they can make it a readily availble feature?

5 replies

Known Participant
September 9, 2025

Hi,

just for curiosity. Are you aware that InDesign 2025 offers a feature to hide a page/spread?
I have just tested it together with the page numbering and as soon as I hide a page the automatic numbering will leave out the hidden  page. Might be useful for your needs?

Thanks Stefan

Participating Frequently
September 9, 2025

Stefan,

Thanks for the info! I was not aware that there was a feature to hide page/spread. I do not want to hide my Section Tabs. They need to remain visible, they need to print, they need to export in the place that they are when creating a .pdf. They just need to be skipped over as though they were a ghost in automatic page numbering. That is how proposals are formatted in the A/E/C community.

Participating Frequently
September 8, 2025

I am attaching the script file. I assigned the first page I wanted to number as a section (SecA) and started automatic page numbering from there (actual 4th page of document after cover letter, transmittal letter, TOC, and first section tab). I created a blank Master Page called "A-Ghost" (Specific name is important as the script looks for the Master Page called "A-Ghost" to apply the script to). I applied the Master Ghost to each subsequent section tab page, and also began a new section (SecB, SecC, etc.) on each section tab page. Then I pulled the .jsx file attached into the correct scripts folder that InDesign wants to reference. Once you run the script, it continues the automatic numbering through the rest of the document. You may have to re-run the script if you delete pages or add pages. (For those of us who want to know the details: The script actually searches for each Ghost page that also begins a new section and instructs the Ghost to duplicate the page number preceeding, then the document continues with automatic numbering. Since section tabs never have a number displayed on them in A/E/C proposals, it is irrelevant what they are called. Then the script continues the automatic page numbering.)

 

// SkipAGhostPages_ManualSections.jsx
// Preserves user-defined sections; only adjusts sections that start on "A-Ghost" parent pages.
// A-Ghost sections now HOLD the previous number correctly (do not consume a count).

(function () {
if (app.documents.length === 0) {
alert("Open a document before running this script.");
return;
}

var doc = app.activeDocument;
var ghostParentName = "A-Ghost";

function isAGhost(page) {
var m = page.appliedMaster;
return m && m.name === ghostParentName;
}

var counterInitialized = false; // becomes true once we hit the first non-A-Ghost section start
var counter = 0; // tracks "next" number for the next non-ghost page
var ghostNeedingSection = []; // A-Ghost pages that are NOT section starts (they will still consume a number)

for (var i = 0; i < doc.pages.length; i++) {
var page = doc.pages[i];
var ghost = isAGhost(page);
var sect = page.appliedSection;
var isSectionStart = sect && (sect.pageStart === page);

if (isSectionStart) {
if (ghost) {
if (counterInitialized) {
// HOLD the previous page's number on this A-Ghost section
sect.continueNumbering = false;
var hold = Math.max(1, counter - 1); // guard against < 1
sect.pageNumberStart = hold;
$.writeln("[A-Ghost] Section at page " + page.name + " -> hold number " + hold);
} else {
// Before main numbering begins; leave it untouched
$.writeln("[A-Ghost] Section at page " + page.name + " before main numbering – left unchanged.");
}
} else {
// Non-ghost section start: DO NOT MODIFY.
// Adopt its start as the current baseline and begin counting from there.
counter = sect.pageNumberStart;
counterInitialized = true;
$.writeln("[Normal] Section at page " + page.name + " defines start number = " + counter);
}
} else {
// Not a section start
if (ghost) {
// This A-Ghost page will still consume a number unless it is a section start.
ghostNeedingSection.push(page.name);
}
}

// Increment the running count only on non-ghost pages *after* numbering has begun
if (!ghost && counterInitialized) {
counter++;
}
}

if (ghostNeedingSection.length > 0) {
alert(
"Done.\n\nNote: The following A-Ghost pages are NOT section starts and will still consume a number:\n" +
ghostNeedingSection.join(", ") +
"\n\nMake each A-Ghost page a Section Start, then re-run the script."
);
} else {
alert("Done.\n• Non-A-Ghost sections preserved\n• A-Ghost section starts now hold the previous number\n• A-Ghost pages excluded from the count");
}
})();

 

Participant
October 8, 2025

Thank you for this! I have a question after I followed the directions. I found that when I started SecA on the first section tab, the following page did not start at one (1), but it started at three (3) (it is page four in the overall document). The rest of the pages are numbered correctly, omitting the other section tabs. In order to get the script to work, I found I had to start a new section on the page that I wanted to be page one (1), and had to select 'start page numbering at one (1)'. I ran the script again, and it worked. Did I miss a step somewhere or did you find you also had to do this? I attached a screenshot of the first section set up.

Participating Frequently
October 8, 2025
Hello!

Thanks for reaching out. Start Section A (or just "A" as I do, but for clarification purposes while explaining I used SecA) on the first page you will want numbered... i.e. the page after your first section tab, and use "Numbering and section options" to assign it to start as page 1. The first several pages... Cover, LOI, TOC, and First Section Tab you will obviously not have masters assigned that call for page numbering. You won't assign Ghost until you get to the actual page of Section B, Section C, etc. Ghost is actually assigned to those section tab pages, and they will also need to have "numbering and section options" assigned to them with a unique identifier (SecB, SecC in my example, but again, I just use B, C, etc.) Does this help?

All the Best,

Kristy Johnson


[cid:295d45db-9a59-4f03-a13d-6423cf2ec33f]
m1b
Community Expert
Community Expert
September 8, 2025

Hi @kristy_0144 if you post your code here, please use the </> formatting button. This makes the code easy to read. Many people share their script on the forum here. It's a good place to start.

brian_p_dts
Community Expert
Community Expert
September 8, 2025

You can post it here. There lots of missing features that have been solved through scripting. Adobe staff monitor these forums. I'm curious to see the problem you are solving for and how.

Fred.L
Inspiring
September 8, 2025

Hey @kristy_0144 
It's nice of you wanting to share your work.

 

I'm thinking about several options :
- Rename and attach your script as a txt file (because I'm not sure the forum accepts .jsx extension files) to your original message, or a new one (if you can't edit your own post). Easy to do, probably not a viable option if you plan to update it. You can also share the raw code in a message, via the formatting tools available when you create a message. Probably not ideal if therer are too many lines in the code.
- create a GitHub account and upload it there. Share the link to your account (It's Free btw). Easy for you to update the script without compromising the links shared with the community

- I've seen people using this plateform as well. It also can be free. payhip_dot_com 

 

My two cents ^^

Fred