Copy link to clipboard
Copied
Hi All,
The below coding is to create margins for master spreads. If any shortcut coding for this.
See my coding below
var mydoc = app.activeDocument;
mydoc.masterSpreads.item(0).
pages.item(0).marginPreferences.top = "6p";
mydoc.masterSpreads.item(0).pages.item(0).marginPreferences.left = "3p";
mydoc.masterSpreads.item(0).pages.item(0).marginPreferences.bottom = "6p";
mydoc.masterSpreads.item(0).pages.item(0).marginPreferences.right = "3p";
mydoc.masterSpreads.item(0).pages.item(1).marginPreferences.top = "6p";
mydoc.masterSpreads.item(0).pages.item(1).marginPreferences.left = "3p";
mydoc.masterSpreads.item(0).pages.item(1).marginPreferences.bottom = "6p";
mydoc.masterSpreads.item(0).pages.item(1).marginPreferences.right = "3p";
alert("Done")
Regards,
Vetha
Or for real brevity: 😉
app.activeDocument.masterSpreads[0].pages.itemByRange(0,1).properties={marginPreferences:{top:'6p',left:'3p',bottom:'6p',right:'3p'}};
Just one point worth noting that using square bracket [0] instead of .item(0) is quite a bit more convenient.
P.s. Marc, Sorry for the plagiary.
Regards
Trevor
Copy link to clipboard
Copied
That code should work just fine as it is, although I must admit it's not how I would do it. Then again ...
As you are clearly a beginner in Javascripting-for-InDesign, I strongly suggest you should not attempt to write any fancy code until you have a clear understanding of the basics. First thing to learn is how to write scripts that do what you need, without using any shortcuts. They will backfire if you don't know what you are doing.
Copy link to clipboard
Copied
Thanks a lot. Like this replies are useful to me...
Copy link to clipboard
Copied
Anyway, here is the track I would suggest:
const MY_PAGE_SETTINGS = {
marginPreferences: { top:'6p', left:'3p', bottom: '6p', right: '3p' },
// etc
};
var mydoc = app.activeDocument;
mydoc.masterSpreads[0].pages.itemByRange(0,1).properties = MY_PAGE_SETTINGS;
alert("Done");
@+
Marc
Copy link to clipboard
Copied
Or for real brevity: 😉
app.activeDocument.masterSpreads[0].pages.itemByRange(0,1).properties={marginPreferences:{top:'6p',left:'3p',bottom:'6p',right:'3p'}};
Just one point worth noting that using square bracket [0] instead of .item(0) is quite a bit more convenient.
P.s. Marc, Sorry for the plagiary.
Regards
Trevor
Copy link to clipboard
Copied
Hi Trevor,
Thanks, I easy to understand. And also I learn new coding from Marc. Thanks a lot both of them.
Regards,
Vetha
Copy link to clipboard
Copied
Thanks
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more