Skip to main content
June 28, 2010
Answered

Find with label?

  • June 28, 2010
  • 3 replies
  • 630 views

1. Is there a way to find pageItems with labels that match a string with javascript? I think you can i Applescript say something like with label like 'test'.

2. If a have the same label on multiple pageItems and select them with app.documents.pageItems.item('test'); i dont get them as an array but as one object of some sort. Is it possible to loop through them?

This topic has been closed for replies.
Correct answer Kasyan Servetsky

You can get them as array like so:

app.documents[0].pageItems.item('test').getElements();

This should for CS3/4, but I read on the forum that CS5 works differently with labels.

Kasyan

3 replies

Inspiring
June 28, 2010

Bear in mind that if you attempt to use .getElements() to convert the result of a call like:

app.documents[0].pageItems.item('test')

into an array, you'll get an "Object is invalid" error if there are no such objects.

There are various ways of working around this.

Dave

Harbs.
Legend
June 28, 2010

http://forums.adobe.com/thread/615381?tstart=0

Kasyan Servetsky
Kasyan ServetskyCorrect answer
Legend
June 28, 2010

You can get them as array like so:

app.documents[0].pageItems.item('test').getElements();

This should for CS3/4, but I read on the forum that CS5 works differently with labels.

Kasyan