Copy link to clipboard
Copied
Anyone have a script that deletes all objects and text outside the page (or margins)?
var objs = app.documents[0].pageItems.everyItem().getElements();
while(obj=objs.pop()){
if(obj.parent instanceof Spread){obj.remove()}
}
Harbs
Copy link to clipboard
Copied
var objs = app.documents[0].pageItems.everyItem().getElements();
while(obj=objs.pop()){
if(obj.parent instanceof Spread){obj.remove()}
}
Harbs
Copy link to clipboard
Copied
I love that 13 years later, I can google how to delete everything off the pasteboard, this thread is still here, and the script still works.
Copy link to clipboard
Copied
See also CleanupPasteboard.js if you need extra parameters and a dialog UI:
http://www.indiscripts.com/post/2009/09/clean-up-your-pasteboard
@+
Marc
Copy link to clipboard
Copied
Unfortunately in my Indi CS6 any pasteboard and spread item is "instance of spread".
So i consider geometrical bounds:
myDocument = app.activeDocument
cur_Ruler = myDocument.viewPreferences.rulerOrigin;
with(myDocument.viewPreferences){
rulerOrigin = RulerOrigin.spreadOrigin;}
myDocument.zeroPoint = [0,0];
aWidth = myDocument.documentPreferences.pageWidth*2+10;
var objs = app.documents[0].pageItems.everyItem().getElements();
while(obj=objs.pop()){
a_left = obj.geometricBounds[1];
a_right = obj.geometricBounds[3];
if(a_right <0 || a_left > aWidth){obj.remove()}
}
with(myDocument.viewPreferences){
rulerOrigin = cur_Ruler} //back to the RulerOrigin
Copy link to clipboard
Copied
This is simpler:
var objs = app.documents[0].pageItems.everyItem().getElements();
while(obj=objs.pop()){
if(obj.parentPage == null){obj.remove()}
}
Harbs
Copy link to clipboard
Copied
Yes! This is great. Thanks, Harbs!