Copy link to clipboard
Copied
Hello,
During the data merge some on some of pages the title text frame has overset text (some titles are long). Is there any method (probably script) that would go through only those frames and resize the text (by setting font size/type)? Making frame auto size is not possible in this case
Best
Moni
1 Correct answer
Scripting is the more elegant solution. Rudimentarily:
var d = app.activeDocument;
var allTfs = d.textFrames;
for (var i = 0; i < allTfs.length; i++) {
while(allTfs[i].overflows) {
allTfs[i].parentStory.pointSize -= .1;
d.recompose();
}
}
Of course, you may want to implement a min point size threshhold, and this would shrink all text frames that contain overset text. This would also not find text frames grouped or otherwise imbedded in other frames; you'd use all
...Copy link to clipboard
Copied
Use GREP style in your paragraph styles to change the size of the text.
Copy link to clipboard
Copied
But how? In GREP there is no property denoting that text is overset?
Copy link to clipboard
Copied
You need to figure out approximately how many characters fit in your text box width/length and create GREP style that reduce the text starting at this number. It might be enough for you. But without seen the complexity of your file it a guess on my part.
Copy link to clipboard
Copied
Ok, I undestand the concept, will try that. Thank you for the idea.
Copy link to clipboard
Copied
Hi Moni,
without writing a script:
Apply a GREP Style to the paragraph style that is applied to the text of that titles.
The GREP pattern will "count" the number of characters and applies a character style with a smaller point size to the text if a certain threshold or number of characters in the paragraph is detected:
GREP Style pattern suggestion for a case with 24 characters or more:
(?=.{24,}$)^.+
Apply a character style that is set to a smaller point size with auto leading.
You could also do a cascade of GREP Styles like the one above for other amounts of characters. See my screenshot below. In all four text frames the same paragraph style is applied. Depending on the number of characters in the paragraph a different character style with a different text size is effective:
Note: In the solution above I assume that your headlines consist of one paragraph only.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Good method, thank you!
Copy link to clipboard
Copied
Just to be sure, it counts only letters/numbers or all characters in a string? (I have things like commas, parenthesis, semicolons, etc in titles)
Copy link to clipboard
Copied
No. It will count everthing spaces included.
Copy link to clipboard
Copied
Scripting is the more elegant solution. Rudimentarily:
var d = app.activeDocument;
var allTfs = d.textFrames;
for (var i = 0; i < allTfs.length; i++) {
while(allTfs[i].overflows) {
allTfs[i].parentStory.pointSize -= .1;
d.recompose();
}
}
Of course, you may want to implement a min point size threshhold, and this would shrink all text frames that contain overset text. This would also not find text frames grouped or otherwise imbedded in other frames; you'd use allPageItems for that.

