//Hello! This script will check that every object you currently have selected fits within the bounds of its current page. If it doesn't, the script will resize it so that it does. This *will also affect images that go out to the bleed*, as this was created to help with ebook conversion. var selection = app.selection; for (i = 0; i < selection.length; i++){ var selectedObject = app.selection[i]; app.viewPreferences.rulerOrigin = RulerOrigin.SPINE_ORIGIN; app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.SPINE_ORIGIN; app.activeDocument.zeroPoint = [0,0]; var page = selectedObject.parentPage; var pageBounds = page.bounds; var pageWidth = pageBounds[1] - pageBounds[3]; if (pageWidth < 0){ pageWidth = pageWidth * -1; } var pageHeight = pageBounds[2] - pageBounds[0]; var margins = page.marginPreferences; var clmnCount = margins.columnCount; var clmnGutter = margins.columnGutter; var startBounds = selectedObject.geometricBounds; var startBoundsHeight = (startBounds[2] - startBounds[0]); var startBoundsWidth = (startBounds[3] - startBounds[1]); var endBounds = startBounds; //Top Check if (endBounds[0] < 0) { endBounds[0] = 0; } //Bottom Check if (endBounds[2] > pageBounds[2]){ endBounds[2] = pageBounds[2]; } //Left Check if (page.side == PageSideOptions.RIGHT_HAND){ //Page is on right hand side if (endBounds[1] < 0){ endBounds[1] = 0; } if (endBounds[3] > pageWidth){ endBounds[3] = pageWidth; } } else { //Page is on left hand side if (endBounds[1] < (0 - pageWidth)){ endBounds[1] = (0 - pageWidth); } if (endBounds[3] > 0) { endBounds[3] = 0; } } selectedObject.geometricBounds = endBounds; //alert("object left: " + endBounds[1] + ", object right: " + endBounds[3]); //alert("page width: " + pageWidth); }