Page-Item Geometry - Adobe 0046100128056 - InDesign - Mac Manual

Javascript
Table of Contents

Advertisement

C
5: Working with Page Items
HAPTER
change the type to a graphic line. The only things that define the type of a rectangle, ellipse, graphic line,
or polygon are:
The number of paths in the object. Any page item with more than one path is a polygon.
The number and location of points on the first path in the object.
To determine the type of a page item, use this example:
var myPageItemType = myPageItem.constructor.name;
The result of the above will be a string containing the type of the page item.
Getting the type of a page item
When you have a reference to a generic page item, and want to find out what type of a page item it is, use
constructor.name to get the specific type.
//Given a generic page item "myPageItem"...
var myType = myPageItem.constructor.name;
alert(myType);
Referring to page items
When you refer to page items inside a given container (a document, layer, page, spread, group, text frame,
or page item), you use the
top level page items inside the object. For example:
var myPageItems = app.documents.item(0).pages.item(0).pageItems;
The resulting collection (
group), objects inside other page items (thought it does contain the parent page item), or page items in
text frames. To get a reference to all of the items in a given container, including items nested inside other
page items, use the
var myAllPageItems = app.documents.item(0).pages.item(0).pageItems;
The resulting collection (
the hierarchy.
Another way to refer to page items is to use their label property, much as you can use the name property
of other objects (such as paragraph styles or layers). In the following examples, we will get an array of page
items whose label has been set to
var myPageItems = app.documents.item(0).pages.item(0).pageItems("myLabel");
If no page items on the page have the specified label, InDesign returns an empty array.

Page-item geometry

If you are working with page items, it is almost impossible to do anything without understanding the way
that rulers and measurements work together to specify the location and shape of an InDesign page item. If
you use the Control panel in InDesign's user interface, you probably are already familiar with InDesign's
geometry, but here is a quick summary:
Object are constructed relative to the coordinates shown on the rulers.
collection of the container object. This gives you a collection of the
pageItems
) does not include objects inside groups (though it does include the
myPageItems
property.
allPageItems
) includes all objects on the page, regardless of their position in
myAllPageItems
myLabel
.
Creating Page Items 57

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs5

Table of Contents