Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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");
}
})();
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now