Search code examples
javascriptadobe-indesign

Add Drop Shadow to All Selected Items in InDesign using Javascript


Trying to figure out how to add drop shadow to all selected items on page within InDesign CC. Here is what I have but it says "Undefined is not an object."

myDS = app.select(SelectAll.ALL);
myDS.dropShadowSettings.mode = ShadowMode.drop;
myDS.dropShadowSettings.angle = .0083;
myDS.dropShadowSettings.xOffset = 0.08;
myDS.dropShadowSettings.yOffset = 0.08;
myDS.dropShadowSettings.size = 0.6;

Solution

  • Then that would be this (although I would prefer check if item has an applied object style and if so edit the object style itself. Then I would look if item has a style already processed to gain performance. But to be brief:

    var allPageItems  = doc.allPageItems;
    var n = allPageItems.length;
    while ( n-- ) process ( allPageItems[n] );
    function process ( item) {
    	if ( !item.properties.transparencySettings ) return;
    	item.transparencySettings.dropShadowSettings.mode = ShadowMode.NONE;
    }