Copy link to clipboard
Copied
I've been using InDesign's desktop version for a while and was accustomed to overriding all master page items using:
However, now that I'm working with InDesign Server 2024, I encounter issues with overriding all master page items. I've been trying to adapt my script to this new environment and have the following code:
function overrideMasterItems(page, masterSpread) {
var masterPageItems = masterSpread.pageItems.everyItem().getElements();
for (var i = 0; i < masterPageItems.length; i++) {
var masterItem = masterPageItems[i];
try {
var bounds = masterItem.geometricBounds;
var overriddenItem = masterItem.override(page);
overriddenItem.geometricBounds = bounds;
if (overriddenItem.allPageItems.length > 0) {
for (var j = 0; j < overriddenItem.allPageItems.length; j++) {
var childItem = overriddenItem.allPageItems[j];
var childBounds = childItem.geometricBounds;
childItem.override(page);
childItem.geometricBounds = childBounds;
}
}
} catch (e) {}
}
}
Despite this, the script doesn't work as expected. Specifically, it seems that not all master page items are being overridden correctly.
Has anyone experienced similar issues or have suggestions for how to properly override master page items in InDesign Server 2024?
Thank you in advance for your help!
You make life too difficult for yourself. To override all page items from a master page on to a document page, use this:
function overrideMasterItems (page) {
var m = page.masterPageItems;
for (var i = m.length-1; i >= 0; i--) {
m[i].override (page);
}
}
Copy link to clipboard
Copied
Not sure why do you need internal loop - when you override parent / container / item that is directly on the page - everything "inside" will be overriden as well.
Your catch...try part is ignoring errors - so you should either disable it or log errors.
Locked / hidden layers / objects won't be overriden.
Copy link to clipboard
Copied
You make life too difficult for yourself. To override all page items from a master page on to a document page, use this:
function overrideMasterItems (page) {
var m = page.masterPageItems;
for (var i = m.length-1; i >= 0; i--) {
m[i].override (page);
}
}