Copy link to clipboard
Copied
Hi,
I have:
2 Masterpages (A-Master + B-Master).
Sequential document -pages-, with odd and even pages. (no "facing" pages).
I want assign odd pages to A-Master and even pages to B-Master.
By "manual" I can type in MasterPage dialogbox: i.e. "1,3,5,7,9" or "2,4,6,8,10".
I would actually like: A-Master: odd and B-Master: even
How do that with script.
myDoc.pages.itemByRange(myStartPage, myEndPage).appliedMaster = myDoc.masterSpreads.item("B-Master");
but... that's a range: from-to ... not a list
Regards,
Jan
Above is just part of the script.
Yes, it works for me, see the whole script below.
Regards,
Jan
//Apply A-MasterPage to odd-pages + B-MasterPage to even pages
//A document with pages must exist.
//A second MasterPages must exist.
//====================================================
if (app.documents.length > 0) main();
function main()
{
var mydoc = app.activeDocument;
//get MasterPages
var everyMaster = mydoc.masterSpreads.everyItem().name;
var masters = ["[None]"];
f
...
Copy link to clipboard
Copied
I found:
// Apply master to the page. i = counter pages
if (i % 2 == 0)
{pages[i].appliedMaster = doc.masterSpreads.itemByName(masters[1]);}
else
{pages[i].appliedMaster = doc.masterSpreads.itemByName(masters[2]);}
Copy link to clipboard
Copied
And does that work for you?
Copy link to clipboard
Copied
Above is just part of the script.
Yes, it works for me, see the whole script below.
Regards,
Jan
//Apply A-MasterPage to odd-pages + B-MasterPage to even pages
//A document with pages must exist.
//A second MasterPages must exist.
//====================================================
if (app.documents.length > 0) main();
function main()
{
var mydoc = app.activeDocument;
//get MasterPages
var everyMaster = mydoc.masterSpreads.everyItem().name;
var masters = ["[None]"];
for (var i = 0; i < everyMaster.length; i++)
{
masters.push(everyMaster[i]);
}
//dialogbox
var maxPages = mydoc.pages.count();
var len = masters.length;
if (confirm("Found Pages: " + maxPages + "\n\n\nFound MasterPages:\n" + masters[1] + "\n" + masters[2] + "\n\n\n\n\nContinue?"))
{
var pages = mydoc.pages;
for (var i = 0; i < pages.length; i++)
{
// Apply master to the page.
if (i % 2 == 0)//remainder
{
pages[i].appliedMaster = mydoc.masterSpreads.itemByName(masters[1]);// odd pages
}
else
{
pages[i].appliedMaster = mydoc.masterSpreads.itemByName(masters[2]);//even pages
}
}
}
}