Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Script for deleting objects on pasteboard

New Here ,
Feb 01, 2010 Feb 01, 2010

Anyone have a script that deletes all objects and text outside the page (or margins)?

TOPICS
Scripting
5.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 01, 2010 Feb 01, 2010

var objs = app.documents[0].pageItems.everyItem().getElements();

while(obj=objs.pop()){

if(obj.parent instanceof Spread){obj.remove()}

}

Harbs

Translate
LEGEND ,
Feb 01, 2010 Feb 01, 2010

var objs = app.documents[0].pageItems.everyItem().getElements();

while(obj=objs.pop()){

if(obj.parent instanceof Spread){obj.remove()}

}

Harbs

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 21, 2023 Sep 21, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 16, 2025 Aug 16, 2025

I have tried it, but it delete page content also !

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 17, 2025 Aug 17, 2025
LATEST

Perhaps try this one: https://www.indiscripts.com/post/2009/09/clean-up-your-pasteboard

It has an option to preserve text frames that have been threaded off of the pasteboard, BUT if removed, will reflow text so shouldn't be removed.

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 01, 2010 Feb 01, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2013 Jan 06, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 06, 2013 Jan 06, 2013

This is simpler:

var objs = app.documents[0].pageItems.everyItem().getElements();

while(obj=objs.pop()){

     if(obj.parentPage == null){obj.remove()}

}

Harbs

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 12, 2013 Jan 12, 2013

Yes! This is great. Thanks, Harbs!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines