//Hello! This script will run through every page in the current document, and check that everything is inside the page bounds. If it isn't, it resizes it so that it is. This *will also affect images that go out to the bleed*, as this was created to help with ebook conversion. if (app.documents.length == 0) { alert ("You must have a document open to run this script"); exit(); } var pageCount = app.activeDocument.pages.length; for (i = 0; i < pageCount; i++){ app.viewPreferences.rulerOrigin = RulerOrigin.SPINE_ORIGIN; app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.SPINE_ORIGIN; app.activeDocument.zeroPoint = [0,0]; var page = app.activeDocument.pages[i]; 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 objects = page.pageItems.everyItem(); var objectCount = page.pageItems.count(); for (a = 0; a < objectCount; a++){ var selectedObject = page.pageItems[a]; 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); }