Copy link to clipboard
Copied
Sometimes my image isn't inserted into the text box; instead, it sits above textFrame
When I am only selecting the image, I want to retrieve the width of the text box.
If the text box isn't split into columns, retrieve the full width of the text box. If it is split into columns, retrieve the width of one column.
(or sometimes it may appear below the text)
Thank you.
Copy link to clipboard
Copied
When you have a textframe that consists of only one column select it and check the Properties Panel or the Control Panel for the width of the frame. If there are two or more columns in the text frame, select it and open the Text Frame Options dialogue with CMD or CTRL B. On the upper right side of the panel you’ll find the width of the column.
Copy link to clipboard
Copied
Sorry, I forgot to mention—I was referring to using scripts.
Copy link to clipboard
Copied
If all you have selected is the image or its container, there would be no reliable way of getting a specific textframe on the page.
If the selection was both the image frame and a text frame you want to target, then you could check the selected objects:
//array of selected objects—the array could be any length
var s = app.activeDocument.selection;
//check each item in the selection
for (var i = 0; i < s.length; i++){
if (s[i].allGraphics.length) {
$.writeln(s[i].allGraphics[0].constructor.name)
} else {
$.writeln(s[i].constructor.name)
}
}; Copy link to clipboard
Copied
Whether a text box is split into columns can be determined using textColumnCount.
app.activeDocument.textFrames[0].textFramePreferences.textColumnCount;
The column width can be obtained using textColumnFixedWidth.
app.activeDocument.textFrames[0].textFramePreferences.textColumnFixedWidth;
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more