Text Item

In the Pages application, text items are another means of displaying text, and are used mostly when a document is in “layout mode” and not incorporating the use of a word-processing text flow between its pages. NOTE: When a document is in layout mode, the value of its document body property of a document is set to false.

This section explores the use of text items and how to edit their text contents, referred to in scripting terms as their object text.

Properties

Documents created by any of the iWork applications, Pages, Numbers, or Numbers, can incorporate a common set of elements, including images, shapes, lines, tables, charts, movies, audio clips, and text items. To AppleScript and the built-in scripting support of the iWork applications, these elements are considered iWork Items, and share a common set of properties, detailed in the iWork Item class from the iWork Suite:

The iWork Suite iWork item Class

iWork item  [inh. iWork item ] : An item which supports formatting.

elements

contained by slides, document.

properties

heightinteger ) : The height of the iWork item.

lockedboolean ) : Whether the object is locked.

parentiWork container r/o ) : The iWork container containing this iWork item.

positionpoint ) : The horizontal and vertical coordinates of the top left point of the iWork item.

widthinteger ) : The width of the iWork item.

responds to

delete, exists

The properties in the iWork item class can be accessed and changed for any of the common iWork elements. For example, a script can get or set the position of a text item, or image, or shape, or any of the common elements.

In addition to sharing a common set of properties with the other iWork elements, each iWork element has its own set of properties, particular to that element. For example, the element-specific properties of a text item are detailed in its dictionary listing, found in the iWork Suite:  (⬇ see below ) 

The iWork Suite text item Class

text item  [inh. iWork item ] : An text container.

elements

contained by slides, document.

properties

background fill typeno fill/‌color fill/‌gradient fill/‌advanced gradient fill/‌image fill/‌advanced image fill, r/o ) : The background, if any, for the text item. NOTE: The value of this property is currently read-only and cannot be changed by a script.

object textrich text ) : The text contained within the text item.

opacityinteger ) : The opacity of the text item container, in percent (0 to 100).

reflection showingboolean ) : Is the text item displaying a reflection?

reflection valueinteger ) : The percentage of reflection of the text item, from 0 (none) to 100 (full).

rotationinteger ) : The rotation of the text item item, in degrees from 0 to 359.

responds to

delete, exists, make

The object text property is used to control the contents of a text item, and will be covered in detail in this section.

NOTE: A text alignment property is not yet implemented in the current scripting dictionary.

Create New Text Item

Here’s an example script that creates a new layout document containing a vertical text item with a story.

TOP | CONTINUE