PageItems
PageItems
Section titled “PageItems”app.activeDocument.pageItems
Description
Section titled “Description”A collection of PageItem objects. Provides complete access to all the art items in an Illustrator document in the following classes:
- CompoundPathItem
- Properties
- Methods
- Example
- GraphItem
- Properties
- Methods
- GroupItem
- Properties
- Methods
- Example
- LegacyTextItem
- Properties
- Methods
- MeshItem
- Properties
- Methods
- Example
- NonNativeItem
- Properties
- Methods
- PathItem
- Properties
- Methods
- Example
- PlacedItem
- Properties
- Methods
- Example
- PluginItem
- Properties
- Methods
- Example
- RasterItem
- Properties
- Methods
- SymbolItem
- Properties
- Methods
- TextFrameItem
- Properties
- Methods
- Example
You can reference page items through the PageItems property in a Document, Layer, or GroupItem.
When you access an individual item in one of these collections, the reference is a page item of one of a particular type. For example, if you use PageItems to reference a graph item, the typename value of that object is GraphItem.
Properties
Section titled “Properties”PageItems.length
Section titled “PageItems.length”app.activeDocument.pageItems.length
Description
Section titled “Description”The number of objects in the collection.
Number; read-only.
PageItems.parent
Section titled “PageItems.parent”app.activeDocument.pageItems.parent
Description
Section titled “Description”The parent of this object.
Object; read-only.
PageItems.typename
Section titled “PageItems.typename”app.activeDocument.pageItems.typename
Description
Section titled “Description”The class name of the referenced object.
String; read-only.
Methods
Section titled “Methods”PageItems.getByName()
Section titled “PageItems.getByName()”app.activeDocument.pageItems.getByName(name)
Description
Section titled “Description”Gets the first element in the collection with the specified name.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
name | String | Name of element to get |
Returns
Section titled “Returns”PageItems.index()
Section titled “PageItems.index()”app.activeDocument.pageItems.index(itemKey)
Description
Section titled “Description”Gets an element from the collection.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
itemKey | String, Number | String or number key |
Returns
Section titled “Returns”PageItems.removeAll()
Section titled “PageItems.removeAll()”app.activeDocument.pageItems.removeAll()
Description
Section titled “Description”Deletes all elements in this collection.
Returns
Section titled “Returns”Nothing.
Example
Section titled “Example”Getting references to external files in page items
Section titled “Getting references to external files in page items”// Gets all file-references in the current document using the pageItems object,// then displays them in a new document
if (app.documents.length > 0) { var fileReferences = new Array(); var sourceDoc = app.activeDocument;
for (var i = 0; i < sourceDoc.pageItems.length; i++) { var artItem = sourceDoc.pageItems[i]; switch (artItem.typename) { case "PlacedItem": fileReferences.push(artItem.file.fsName); break; case "RasterItem": if (!artItem.embedded) { fileReferences.push(artItem.file.fsName); } break; } }
// Write the file references to a new document var reportDoc = documents.add(); var areaTextPath = reportDoc.pathItems.rectangle(reportDoc.height, 0, reportDoc.width, reportDoc.height); var fileNameText = reportDoc.textFrames.areaText(areaTextPath); fileNameText.textRange.size = 24; var paragraphCount = 3; var sourceName = sourceDoc.name; var text = "File references in \'" + sourceName + "\':\r\r"; for (i = 0; i < fileReferences.length; i++) { text += (fileReferences[i] + "\r"); paragraphCount++; } fileNameText.contents = text;}