: How to apply a master page to every Nth page? Is there a expression/code in "apply master page" dialogue to apply selected master to every n pages, for example every 6th page? Any scripts suggestions
Is there a expression/code in "apply master page" dialogue to apply selected master to every n pages, for example every 6th page?
Any scripts suggestions will be appreciated!
More posts by @Lengel450
2 Comments
Sorted by latest first Latest Oldest Best
I have made a script that should accomplish what you want.
The main functionality of the script (the first part) is commented and pretty straight-forward (if you know javascript). I have added a small input dialog to make the script easy to use, but I haven't commented that part of the code.
Copy the code below to a text editor and save it as a .jsx file (for example ApplyMasterToEveryNthPage.jsx) in the folder for user scripts.
In InDesign, run the script and a dialog box will appear. Here you choose which master to use, the first page to apply it to and the interval (n).
Let me know if it works for you.
// APPLY MASTER TO EVERY NTH PAGE
// Copyright (c) 2017 Mads Wolff
// This script is distributed under the MIT License.
// MAIN FUNCTIONALITY
// Make a reference to the "pages" of the active document.
var pages = app.activeDocument.pages;
// Make a reference to the "masterSpreads" of the active document.
var masterSpreads = app.activeDocument.masterSpreads;
// Applies a master to every nth page starting at a certain page.
// Takes 3 arguments:
// masterName the name of the master spread
// firstPage the first page to apply the master to
// interval the interval (n) to apply the master at
function applyMasterToEveryNthPage(masterName, firstPage, interval) {
// Make a reference to the "masterSpread" to apply.
var masterSpread = masterSpreads.item(masterName);
// Iterate through the "pages" at the chosen "interval", starting at the chosen "firstPage".
for (var i = firstPage - 1; i < pages.length; i += interval) {
// Make a reference to the "page".
var page = pages.item(i);
// Apply the "masterSpread" to the "page" by setting its "appliedMaster" attribute.
page.appliedMaster = masterSpread;
}
}
// DIALOG
// Stores all the names of the document's master spreads in an array.
function getMasterSpreadNames() {
var masterSpreadNames = new Array;
for(i = 0; i < masterSpreads.length; i++){
masterSpreadNames.push(masterSpreads.item(i).name);
}
return masterSpreadNames;
}
// Displays the input dialog.
function displayDialog(){
var dialog = app.dialogs.add({name:"Add Master To Every Nth Page"});
var masterSpreadNames = getMasterSpreadNames();
with (dialog) {
with (dialogColumns.add()) {
with (borderPanels.add()) {
with (dialogColumns.add()) {
staticTexts.add({staticLabel:"Master:"});
staticTexts.add({staticLabel:"First page:"});
staticTexts.add({staticLabel:"Interval:"});
}
with (dialogColumns.add()) {
var masterNameDropdown = dropdowns.add({stringList: masterSpreadNames, selectedIndex: 0, minWidth: 200});
var firstPageField = integerEditboxes.add({editValue: 1, minimumValue: 1, maximumValue: pages.length});
var intervalField = integerEditboxes.add({editValue: 2, minimumValue: 1, maximumValue: pages.length});
}
}
}
}
var dialogReturn = dialog.show();
if (dialogReturn == true) {
var masterName = masterSpreadNames[masterNameDropdown.selectedIndex];
var firstPage = firstPageField.editValue;
var interval = intervalField.editValue;
dialog.destroy();
applyMasterToEveryNthPage(masterName, firstPage, interval);
} else {
dialog.destroy();
}
}
displayDialog();
The best thing I can come up with is to generate the required page number sequence in 3-rd party software (like Excel) and then paste it in "apply..." field. Seems to work with documents several hundred pages long.
For example, in Excel put in A1 cell the initial page you want to apply master to.
Then, in B1 cell type A1+N.
Then apply and drag B1 by bottom right corner to the right for as many numbers as you wish. You'll have to copy the whole line of cells and replace tab symbols with commas.
Or you can use online tools like rechneronline.de/number-list/
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.