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

Get all anchored objects (CS4 Javascript)

People's Champ ,
Aug 17, 2010 Aug 17, 2010

Copy link to clipboard

Copied

Hi,

I'm trying to get all anchored objects in a document. This is what I've come up with:

var myAOs = [];
myItems = app.activeDocument.allPageItems;
for (aa=0; aa<myItems.length; aa++){
   if (myItems[aa].parent instanceof Character)  myAOs.push(myItems[aa])
}

Is there a better way to do this?

Thanks,

Ariel

TOPICS
Scripting

Views

347

Translate

Translate

Report

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 , Aug 17, 2010 Aug 17, 2010

app.documents[0].stories.everyItem().pageItems.everyItem().getElements();

This will get you all anchored page items except ones in tables and footnotes.

For footnotes, you'd add in an extra footnotes.everyItem()

For Tables, I think .pageItems.everyItem() will work, but I'm not positive.

If you need nested tables, you might want to use tables.allPageItems.

Harbs

Votes

Translate

Translate
LEGEND ,
Aug 17, 2010 Aug 17, 2010

Copy link to clipboard

Copied

app.documents[0].stories.everyItem().pageItems.everyItem().getElements();

This will get you all anchored page items except ones in tables and footnotes.

For footnotes, you'd add in an extra footnotes.everyItem()

For Tables, I think .pageItems.everyItem() will work, but I'm not positive.

If you need nested tables, you might want to use tables.allPageItems.

Harbs

Votes

Translate

Translate

Report

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
People's Champ ,
Aug 17, 2010 Aug 17, 2010

Copy link to clipboard

Copied

LATEST

Very nifty!

So now I can just tag on:

app.activeDocument.stories.everyItem().pageItems.everyItem().fit(FitOptions.FRAME_TO_CONTENT)

and hey presto! all anchored objects are reduced to size! Nice and quick, too!

I'm just not entirely clear why the page items of a story are anchored objects, but not the page items of a document?

Thanks,

Ariel

Votes

Translate

Translate

Report

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