Text Items

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.

Text Item Containers

In the iWork applications, there are two container types for text items:

 1  Labels • Are the default text item created using scripts, the text toolbar button, or the Insert menu. Label containers have two horizontal adjustment handles and automatically wrap vertically to fit their object text.

 2  Boxes • Are text items with eight adjustment handles, allowing them to be sized both vertically and horizontally, regardless of their object text. NOTE: a text item label can be converted to a text item box by adjusting its column count to 2 and then back to 1.

text-item-types
◆ Title & Subtitle

An example script that creates a title and subtitle text items centered on the document page:

(⬇ see below ) The Print Setup window for A Numbers document with centered title and subtitle. The page size is set for U.S. Letter, and the left and right margins are set to 0.

centered-text-items

TOP | CONTINUE