EasyManua.ls Logo

Adobe 0046100128056 - InDesign - Mac - Page-item geometry

Adobe 0046100128056 - InDesign - Mac
209 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 5: Working with Page Items Creating Page Items 57
change the type to a graphic line. The only things that define the type of a rectangle, ellipse, graphic line,
or polygon are:
X The number of paths in the object. Any page item with more than one path is a polygon.
X 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
pageItems collection of the container object. This gives you a collection of the
top level page items inside the object. For example:
var myPageItems = app.documents.item(0).pages.item(0).pageItems;
The resulting collection (myPageItems) does not include objects inside groups (though it does include the
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
allPageItems property.
var myAllPageItems = app.documents.item(0).pages.item(0).pageItems;
The resulting collection (myAllPageItems) includes all objects on the page, regardless of their position in
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
myLabel.
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 InDesigns
geometry, but here is a quick summary:
X Object are constructed relative to the coordinates shown on the rulers.

Table of Contents

Related product manuals