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
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
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
Copy link to clipboard
Copied
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