Dropshadow > Size is limited to 0-144 points within scripting but you can enter higher numbers manually 0-1000 points
My understanding is indesign dropshadow effect needs to be updated for the option: size within the dropshadow panel to be able to accept 0 - 1000 points for scripts. You can input higher numbers within the size by doing it manually but not with scripts for whatever reason. It will only accepts 0-144 point or 2 inches within the code.
- Indesign CC 2025
- Run the attached script a 100 in height image and you'll get the error.
- On the dropshadow applied to have the distance 5.0 in and size 5.0
- Distance: 5.0 in and Size: 0.0694 in
- Script attached.
I have a script to automatically apply dropshadows and we have a formula where we take the height of the image and multiply that by 5% which gets placed in the Distance and Size. This works for smaller images but when there are larger images the number it puts into the distance works but the size seems to be limited to 2 inches. But if I do it manually it can go up to 13.8889″
for the size
I get this error: ERROR in applyDropShadow: Error: Invalid value for set property ‘size’. Expected Unit (0 - 144 points), but received “5.0 in”. 13.8889 in = 1000 points
//@target "indesign"
//@targetengine "session"
function isValidObject(obj) {
try {
return obj && obj.isValid;
} catch (e) {
return false;
}
}
function applyDropShadowByHeightInInches(obj) {
if (!isValidObject(obj)) return;
var doc = app.activeDocument;
var originalH = doc.viewPreferences.horizontalMeasurementUnits;
var originalV = doc.viewPreferences.verticalMeasurementUnits;
try {
// Switch the document to inches.
doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.INCHES;
doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.INCHES;
// geometricBounds => [y1, x1, y2, x2] in INCHES now.
var bounds = obj.geometricBounds;
var heightInches = Math.abs(bounds[2] - bounds[0]); // bottom - top
// 5% of height in inches
var dropShadowInches = heightInches * 0.05;
// Apply the drop shadow
var ds = obj.transparencySettings.dropShadowSettings;
ds.mode = ShadowMode.DROP;
ds.angle = 120; // Static angle
ds.distance = dropShadowInches; // in inches
ds.size = dropShadowInches; // same as distance
ds.opacity = 35; // example opacity
ds.noise = 2.5; // example noise %
ds.xOffset = 0;
ds.yOffset = 0;
ds.spread = 0;
} catch (e) {
$.writeln("Error applying shadow: " + e);
} finally {
// Restore original measurement units
doc.viewPreferences.horizontalMeasurementUnits = originalH;
doc.viewPreferences.verticalMeasurementUnits = originalV;
}
}
function main() {
if (app.documents.length === 0) {
alert("No open documents.");
return;
}
var doc = app.activeDocument;
if (!isValidObject(doc)) {
alert("Active document not valid.");
return;
}
if (app.selection.length === 0) {
alert("No objects selected.");
return;
}
var count = 0;
for (var i = 0; i < app.selection.length; i++) {
var obj = app.selection[i];
if (isValidObject(obj)) {
applyDropShadowByHeightInInches(obj);
count++;
}
}
alert("Drop shadow applied to " + count + " object(s).");
}
main();