words(container, [cb])

Returns a collection of all word objects in the given container. The container object can be a Document, Page, Layer, Group, Story, Text Frame, Paragraph or Line. If a callback function is given, words() calls this callback function on each word object of the given container. When the callback function returns false, the loop stops and the words() function returns an array of all words up to this point.

Type: function

Parameter(s):

  • container {Document | Page | Layer | Group | Story | TextFrame | Paragraph | Line}:

    The document, page, layer, group, story, textFrame, paragraph or line instance to iterate the words in.

  • cb {Function} Optional:

    Optional: The callback function to call with each word. When this function returns false the loop stops. Passed arguments: word, loopCount

Returns:

  • {Words | Array}:

    A collection or an array of Word objects.