Answered
Using Javascript to change marginPreferences, then restore them
Hi all,
I'm working on a script that changes the left and right margin of all pages to 0.
However, I want to be able to store the original margins (see lines 8 & 9) so I can restore them later (see lines 25 & 26).
I can't seem to work out exactly how that's done without getting expected array errors, etc.
Be great if someone can help. J
app.scriptPreferences.measurementUnit = MeasurementUnits.MILLIMETERS;
var myDoc = app.activeDocument;
var myMasters = myDoc.masterSpreads.everyItem().pages.everyItem();
var myPages = myDoc.pages.everyItem();
//store original preferences???
var origPagePrefs = myPages.marginPreferences;
var origMasterPrefs = myMasters.marginPreferences;
//left and right margins set to 0mm. Uncomment to include more.
var marginPrefs = {
left: 0,
right: 0,
//top: 10,
//bottom: 10,
//columnCount: 6,
//columnGutter: 5
}
myMasters.properties = {marginPreferences : marginPrefs};
myPages.properties = {marginPreferences : marginPrefs};
//restore original margins
//myMasters.properties = {marginPreferences : origMasterPrefs};
//myPages.properties = {marginPreferences : origPagePrefs};
