I'm looking for a quick way to move a text box fra coordinate x/y to coordinate a/b - and changing it from 200 pixel width to 680. From within an image, to just beneath it.
Ihave the same template for several pages (daily newspaper), and this operation is going to be done a lot during the week. If this can be done using a script, I can assign a keystroke to this script, and then move/change the text block with one quick keyboard shortcut.
Is it possible?
Here are some snippets that might help:
// step 1: change document rulers to pixels, to make the math easier
app.activeDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.PIXELS;
app.activeDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.PIXELS;
// step 2: move the selected box to your new coordinates. Here, x comes first
// get an array containing the bounds of the text frame
var frameBounds = app.selection.geometricBounds;
// calculate the new X2 coordinate and insert it into the array
frameBounds = 200 + frameBounds;
// apply the new array to the selected frame
app.selection.geometricBounds = frameBounds;
It's considered good form to reset the measurement units to their previous state. But maybe you want all pages in pixels. I usually work in points and I hear complains when one of my scripts fails to restore the designer's preferred ruler.
The "move" command works relative to the ruler origin, which can also be controlled by script if that's an issue. We use pages with margins, so I set "app.activeDocument.zeroPoint" to the top and left margins.
If you're going to put this into the hands of a lot of users, you'll want to do some checking to make sure a textFrame is selected before anything else happens. app.selection could be a lot of different things.