The InDesign Object Model

This  diagram shows a conceptual overview of the InDesign document object model; it is not a comprehensive list of the objects available to InDesign extensions, and does not necessarily show the ActionScript names of the objects.

ID_DOM_overview.gif

The root of the class hierarchy is the singleton Application object.  To access the InDesign Application object in ActionScript use this code:

import com.adobe.csawlib.indesign.InDesign;
import com.adobe.indesign.Application;
var app:com.adobe.indesign.Application = InDesign.app;

 

Term used in diagram

Represents

Application

The InDesign application, root of the class hierarchy.

Application defaults

Application default settings, such as colors, paragraph styles, and object styles. Application defaults affect all new documents.

Application events

Application-level events. Events are generated by opening, closing, or saving a document or choosing a menu item.

Application menus

The menus, submenus, and context menus displayed in the InDesign user interface.

Application methods

The actions the application can take; for example, finding and changing text, copying the selection, creating new documents, and opening libraries.

Application preferences

For example, text preferences, PDF export preferences, and document preferences. Many of the preferences objects also exist at the document level. Just as in the user interface, application preferences are applied to new documents. Document preferences change the settings of a specific document.

Application properties

The properties of the application; for example, the full path to the application, the locale of the application, and the user name.

Books

A collection of open books.

Document

An InDesign document.

Document defaults

Document default settings, such as colors, paragraph styles, and text formatting defaults.

Document elements

For example, the stories, imported graphics, and pages of a document. The figure that precedes this table shows pages and stories, because those objects are very important containers for other objects, but document elements also include rectangles, ovals, groups, XML elements, and any other type of object you can import or create.

Document events

Events that occur at the document level, such as importing text.

Document methods

The actions the document can take; for example, closing a document, printing a document, and exporting a document.

Document preferences

The preferences of a document, such as guide preferences, view preferences, and document preferences.

Document properties

For example, the document filename, number of pages, and zero point location.

Documents

A collection of open documents.

Libraries

A collection of open libraries.

Page

A single page in an InDesign document.

Page items

Any object you can create or place on a page. There are many types of page items, such as text frames, rectangles, graphic lines, or groups.

Pages or spreads

The pages or spreads in an InDesign document.

Stories

The text in an InDesign document.

Text objects

Characters, words, lines, paragraphs, and text columns are examples of text objects in an InDesign story.

The layer object model

The following figure shows the layer object model. This diagram focuses on the location of a layer and its contents in the context of the object hierarchy of a document; it does not attempt to show all the other ways a script might work with the content of a layer; for example, you can get a reference to a text-frame object from a story, text object, page, or spread, in addition to finding it inside a layer object.

The basic properties of a Layer are shown on the left, the object collections on the right.

id_layers.png

Note the distinction between the pageItems collection, which contains only the top-level page items in a layer, and the allPageItems collection, a flattened collection of all page items assigned to the layer, regardless of their location in the object hierarchy.  If a page item is inside a group, for example, it does not appear in the pageItems collection.  A PageItem object points back to the layer it belongs to in the itemLayer property; you can change the containing layer by setting this value. When you do so, the item lists in the affected layers are automatically updated.

Similarly, the allGraphics property contains all graphics stored in page items assigned to the layer, regardless of their location in the object hierarchy.

The page item model

Page items in an InDesign layout are arranged in a hierarchy, and appear within a container object of some sort. Spreads, pages, other page items, groups, and text characters are all examples of objects that can contain page items. This hierarchy of containers in the InDesign scripting object model is the same as in the InDesign user interface; when you create a rectangle by dragging the Rectangle tool on a page, you are specifying that the page is the container, or parent, of the rectangle. When you paste an ellipse into a polygon, you are specifying that the polygon is the parent of the ellipse, which, in turn, is a child object of its parent, a page.

The text model

The following diagram shows a view of InDesign’s text object model. As you can see, there are two main types of text object: layout objects (text frames) and text-stream objects (for example, stories, insertion points, characters, and words):

id_text1.png

There are many ways to get a reference to a given text object. The following diagram shows a few ways to refer to the first character in the first text frame of the first page of a new document:

id_text2.png

For any text stream object, the parent of the object is the story containing the object. To get a reference to the text frame (or text frames) containing the text object, use the parentTextFrames property.

For a text frame, the parent of the text frame is typically the page or spread containing the text frame. If the text frame is inside a group or was pasted inside another page item, its parent is the containing PageItem. If the text frame was converted to an anchored frame, its parent is the character containing the anchored frame.

 

 

 

 

 

Copyright © 2010 Adobe Systems Incorporated. All rights reserved.