Reply To: Change page number style depending on page

Home Page / Forums / General InDesign Topics (CLOSED) / Change page number style depending on page / Reply To: Change page number style depending on page

#89048
Matt Isaac
Participant

The only way i know of to do this is with scripting. There may or may not be a way using InDesign’s built-in features. create a paragraph style with the styling the way you want all the numbers to appear and name that style “Page Numbering”, then create a character style the way you want the current page number to be formatted and name this style “Current Page” and run this script:


/*
Scripted by Skemicle
1:00 PM 10/17/2016
*/
if (parseFloat(app.version) < 6)
main();
else
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Add page numbers in reverse");
function main() {
	doc = app.activeDocument;
	prefs = doc.viewPreferences;
	hmu = prefs.horizontalMeasurementUnits;
	vmu = prefs.verticalMeasurementUnits;
	prefs.horizontalMeasurementUnits = MeasurementUnits.INCHES;
	prefs.verticalMeasurementUnits = MeasurementUnits.INCHES;
	var ro = doc.viewPreferences.rulerOrigin;
	doc.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
	page = doc.pages;
	pages = [];
	userlayer = doc.activeLayer;
	try{
		doc.layers.itemByName("Page Numbering").remove()
	}catch(er){};
	doc.layers.add({name:"Page Numbering"});
	pageHeight = doc.documentPreferences.pageHeight;
	pageWidth = doc.documentPreferences.pageWidth;
	leftMargin = doc.marginPreferences.left;
	rightMargin = pageWidth - doc.marginPreferences.right;
	bottomMargin = pageHeight - doc.marginPreferences.bottom;
	for(c=0;c<page.length;c++){
		pages[c] = c + 1
	}pageNumbers = pages.join(" ");
	for(c=0;c<page.length;c++){
		numbersFrame = page[c].textFrames.add({contents:pageNumbers, geometricBounds:[bottomMargin,leftMargin,bottomMargin + .25,rightMargin]});
		numbersFrame.insertionPoints[0].appliedParagraphStyle = "Page Numbering";
		word = numbersFrame.words
		for(n=0;n<word.length;n++){
			if(word[n].contents == c + 1){
				word[n].appliedCharacterStyle = "Current Page";
			}
		}
	}
	doc.layers.itemByName("Page Numbering").locked = true;
	app.activeDocument.activeLayer = userlayer;
	doc.viewPreferences.rulerOrigin = ro;
	prefs.horizontalMeasurementUnits = hmu;
	prefs.verticalMeasurementUnits = vmu;
}

For information on installing and using this script see: https://creativepro.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post.php

This article was last modified on October 17, 2016

Comments (0)

Loading comments...