Copy link to clipboard
Copied
Hello All,
I just want ask, whethere any possibilites are there in scripting to delete the text and path items present outside the artboard.
For Example:
I want to delete the rectangles and text present outside artboard for 100's of files. As of now, I am doing manually.
Please let me know any possible and quick way using scripting.
This should delete anything partly or completely outside the one artboard:
var doc = app.activeDocument;
var items = doc.pageItems;
for (var i = items.length - 1; i > -1; i--) {
var b1 = items[i].geometricBounds;
var b2 = doc.artboards[0].artboardRect;
if ((b1[0] < b2[0] || b1[2] > b2[2]) ||
(b1[1] > b2[1] || b1[3] < b2[3])) {
items[i].remove();
}
}
This should delete anything completely outside the one artboard:
var doc = app.activeDocument;
var items = doc.page
...
here's a very crude alternative for educational purposes
app.executeMenuCommand ("selectallinartboard");
app.executeMenuCommand ("Inverse menu item");
app.executeMenuCommand ("clear");
Copy link to clipboard
Copied
This should delete anything partly or completely outside the one artboard:
var doc = app.activeDocument;
var items = doc.pageItems;
for (var i = items.length - 1; i > -1; i--) {
var b1 = items[i].geometricBounds;
var b2 = doc.artboards[0].artboardRect;
if ((b1[0] < b2[0] || b1[2] > b2[2]) ||
(b1[1] > b2[1] || b1[3] < b2[3])) {
items[i].remove();
}
}
This should delete anything completely outside the one artboard:
var doc = app.activeDocument;
var items = doc.pageItems;
for (var i = items.length - 1; i > -1; i--) {
var b1 = items[i].geometricBounds;
var b2 = doc.artboards[0].artboardRect;
if ((b1[2] < b2[0] || b1[0] > b2[2]) ||
(b1[3] > b2[1] || b1[1] < b2[3])) {
items[i].remove();
}
}
Copy link to clipboard
Copied
Thank You So Much @femkeblanco
Copy link to clipboard
Copied
here's a very crude alternative for educational purposes
app.executeMenuCommand ("selectallinartboard");
app.executeMenuCommand ("Inverse menu item");
app.executeMenuCommand ("clear");
Copy link to clipboard
Copied
Thank You So Much @CarlosCanto
Copy link to clipboard
Copied
this works only for one page, but when i have a multi-artboard it deletes all except the active artboard.
Could you please re-script to make it delete all out artboard without deleting inside multi-artboard