I'm trying to size a text frame to fit the width of it's contents.
Possible??
Thank you.
I know the name of the text frame, so I try:
tell application "Adobe InDesign CS5.5"
tell the active document
tell the text frame PersonalizeOneT
fit given frame to content
end tell
end tell
end tell
This doesn't work.
Undeclared variable.
Sorry for the stupid questions. Applescript syntax confuses the heck out this old php programmer !
The green color indicates a script variable… as you have not previously set/declaired it… it's not vaild… If it's some sting property then wrap it in double quotes for AppleScript… eg
tell application "Adobe InDesign CS5"
tell the active document
set Text_Frame to the first text frame whose label is "test"
tell Text_Frame to fit given frame to content
end tell
end tell
Mark -
We are getting closer:
tell application "Adobe InDesign CS5.5"
tell the active document
set Text_Frame to the text frame "PH"
tell Text_Frame to fit given frame to content
end tell
end tell
works, but it only fits the frame to the height, not the width.
Frame contains three lines of text, all centered.
Any more thoughts???
Shane's right ;-)
Getting it from the left:
tell application "Adobe InDesign CS5.5"
tell the active document
set Text_Frame to item 1 of (every text frame whose label is "PH")
tell Text_Frame
set theLines to every line
--get maxLineLength
set maxLength to null
repeat with i from 1 to count of theLines
set {start, stopp} to {horizontal offset of line i, end horizontal offset of line i}
set currentLineLength to stopp - start
if i is 1 then
set maxLength to currentLineLength
else
if currentLineLength is greater than maxLength then
set maxLength to currentLineLength
end if
end if
end repeat
--set x2-bounds of Text_Frame
set {y1, x1, y2, x2} to visible bounds
set visible bounds to {y1, x1, y2, x1 + maxLength}
--fit height
fit given frame to content
end tell
end tell
end tell
Hope it'll work ![]()
Hans-Gerd Claßen
Hope it'll work
It will nearly all the time, but it's worth a check afterwards to make sure. It can fail if, for example, the last text on the longest line is a long auto page number; InDesign gives the wrong width for those.
Also, it's a fraction quicker to say:
set Text_Frame to (text frame 1 whose label is "PH")
rather than:
set Text_Frame to item 1 of (every text frame whose label is "PH")
North America
Europe, Middle East and Africa
Asia Pacific