Article View: adobe.scripting.indesign
Article #137Re: [JS] checking type of pageItem
From: Kasyan_Servetsky
Date: Thu, 02 Apr 2009 17:20
Date: Thu, 02 Apr 2009 17:20
8 lines
1464 bytes
1464 bytes
From Adobe InDesign CS2 Scripting Guide (pages 13-14)
When you are iterating through a collection, JavaScript insists that the type of the item is the type of the
collection. When you iterate through a pageItems collection, for example, the type of each item will be
PageItem, rather than Rectangle, Oval, Polygon, GraphicLine, or TextFrame. To get the specific type
of an item when you are iterating through a collection of unlike items, use the getElements() method, as
shown in the following example:
for(myCounter = 0; myCounter < app.activeDocument.pages.item(0).pageItems.length; myCounter ++){ var myPageItem = app.activeDocument.pages.item(0).pageItems.item(myCounter); var myPageItemType = myPageItem.getElements()[0].constructor.name; alert(myPageItemType); }
Technical Details
Message-ID:
<59b87b76.2@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!newshub.sdsu.edu!webcrossingReferences:
<59b87b76.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,1898028eb4bd8c65 X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Kasyan_Servetsky@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: [JS] checking type of pageItem Message-ID: <59b87b76.2@webcrossing.la2eafNXanI> Date: Thu, 2 Apr 2009 10:20:47 -0700 References: <59b87b76.-1@webcrossing.la2eafNXanI> Lines: 18 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit