Resize anchored objects with script as per the item width
- September 3, 2022
- 1 reply
- 515 views
I have created this custom leader which is a line (it may be a vector graphic as well).
Currently I have anchored this line after the page number and given it an object style.
Issue is that all the Table of Contents items are not of uniform size so the line is
overlapping the TOC items.
I wanted to write a script which will automatically reduce the size of the anchored line
or graphic from right side (for vector graphics, i'll put the vector inside the box and
change the size of the box as per requirement).
My knowledge of indesign script is nil. I do have some idea of coding.
Somehow I got the following code to get the number of anchored objects.
I modified the code but it aint working. Nothing happens. It only shows
the count of anchored object which again is a matter of concern as there are other anchored objects which
I dont want to touch. It should only read the vectors I use instead of leaders.
Screenshot attached.
Here is the code:
---------------------------
allAnchObjects = app.activeDocument.stories.everyItem().pageItems.everyItem().getElements();
for (i=0; i<allAnchObjects.length; i++)
{
alert(allAnchObjects.length);
//allAnchObjects[i].resize (BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS,AnchorPoint.TOP_LEFT_ANCHOR,ResizeMethods.ADDING_CURRENT_DIMENSIONS_TO,[ 0, 10 ]);
//Set the anchor point to the left side. Meaning Lock the left side.
app.activeDocument.layoutWindows[0].transformReferencePoint = AnchorPoint.LEFT_CENTER_ANCHOR;
//allAnchObjects[i].resize (BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS,AnchorPoint.RIGHT_CENTER_ANCHOR,ResizeMethods.ADDING_CURRENT_DIMENSIONS_TO,[ 0, 10 ]);
allAnchObjects[i].resize (BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS,AnchorPoint.LEFT_CENTER_ANCHOR,ResizeMethods.ADDING_CURRENT_DIMENSIONS_TO,[ 0, 10 ]);
}
Thanks and regards
