Quantcast
Channel: Select, adjust and distribute textframes in InDesign [ExtendScript] - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Select, adjust and distribute textframes in InDesign [ExtendScript]

$
0
0

I want to write a script that does the following:

  • select some textframes
  • center the selection horizontally
  • distribute the frames horizontally
  • the whole routine has to be done on several pages

My first problem is, that I only want to select textframes from a unlocked layer. I found several solutions where all textframes, even on locked layers, were selected.And the only solution I found so far that just selects the textframes from my unlocked layer (app.menuActions.item("$ID/Select &All").invoke();) doesn't provide an object I can work with (adjust, distribute) afterwards.

Is there a solution to my requirements?


Edit:My last attempt looked like this (for a single page, I didn't used a loop for several pages while testing):

// 'allPageItems' erfasst alle Rahmen, zusätzlich Gruppen und Bilder var allObjects = app.activeDocument.layoutWindows[0].activeSpread.allPageItems; // eine Schleife durch die Objekte for (var n=0; n<allObjects.length; n++) {     var curObject = allObjects[n];     // prüfen, ob Textrahmen     if (curObject.constructor.name == "TextFrame") {         // verankerte Textrahmen ausschliessen         if (curObject.parent != "[object Character]") {             // zur Auswahl hinzufügen             curObject.select(SelectionOptions.ADD_TO);         }       } } 

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images