Copy link to clipboard
Copied
I use data merge to create labels for guests attending functions. Usually this is around 500-1000 labels at one time. I usually set my text frame on the template page for a large point and then shrink it horizontally (I do this to minimize the number of pages I have to manually edit for overset text). I still get some names where they are long hyphenated names that create overset text.
Is there a script available where it will recognize there is overset text and then shrink the text down either by decreasing the point size or adjusting the horizontal spread of the text (maybe making it 100% to 80%)?
Copy link to clipboard
Copied
I think the answer was in an earlier post: http://forums.adobe.com/message/4763303
In short, it is one of two answers:
colly
Copy link to clipboard
Copied
I want to maintain the same frame size since I have First Name and Last Name on two lines and it's already stretched out to the edges of the workspace I have.
I did review that link before I posted. It didn't really work. Was hoping there was a script instead.
I am using CS5, FYI.
Copy link to clipboard
Copied
OK, so the first solution is out not only due to the version of InDesign but also because the frame is to stay the same size.
The GREP solution should work. By "it didn't really work", can you elaborate? What appeared to foul up or not perform as expected?
Perhaps another solution is this: http://in-tools.com/article/scripts-blog/fun-with-text-fitting-in-indesign/
Copy link to clipboard
Copied
Hi,
You could try this:
#target indesign
myDoc = app.activeDocument;
var textArr = new Array(), mRes, myPit, count, done;
mFramesToMove = new Array();
myPit = myDoc.allPageItems; // array with doc pageItems (masterpages and groups included)
for (var k = 0; k < myPit.length; k++)
if (myPit
.constructor.name == "TextFrame" && myPit .overflows ) textArr.push(myPit
); // array with overset textFrames count = textArr.length;
if (count) mRes = mDialog (count);
else {alert ("No overset texts found"); exit (); }
for (var i = 0; i < textArr.length; i++) {
done = mShrink (textArr, mRes);
if (!done[0] ) {
alert (done[1] + "\rFill a dialog field with a number");
exit; }
}
if (mFramesToMove.length) {
if (myDoc.layers.item("Overset frames").isValid)
mLayer = myDoc.layers.item("Overset frames");
else
mLayer = myDoc.layers.add({LocationOptions: LocationOptions.AT_BEGINNING, name: "Overset frames"});
for (var i = 0; i < mFramesToMove.length; i++)
mFramesToMove.itemLayer = mLayer;
alert ("Some frames (" + mFramesToMove.length + ") stay overset\rTake a look at layer 'Overset Frames' ");
}
else alert (count + " frames overset fixed");
function mDialog (number) {// "What to do" dialog
var w = new Window("dialog","What to do?", undefined, {closeButton: false});
w.add ("statictext", undefined, "Number of overset texts found: " + number.toString() );
var myTop = w.add ("panel");
myTop.alignment = "left";
myTop.orientation = "row";
var myCheckBx = myTop.add ("group");
myCheckBx.orientation = "column";
myCheckBx.alignChildren = "left";
var Ch1 = myCheckBx.add("checkbox", undefined, "point size limit: ");
var Ch2 = myCheckBx.add("checkbox", undefined, "hori scale limit: ");
var myEditBx = myTop.add ("group");
myEditBx.orientation = "column";
var Ed1 = myEditBx.add("edittext", undefined, undefined);
Ed1.enabled = false; Ed1.characters = 4;
var Ed2 = myEditBx.add("edittext", undefined, undefined);
Ed2.enabled = false; Ed2.characters = 4;
Ch1.onClick = function () {
if (Ch1.value) Ed1.enabled = true;
else Ed1.enabled = false;}
Ch2.onClick = function () {
if (Ch2.value) Ed2.enabled = true;
else Ed2.enabled = false;}
var myStatBx = myTop.add ("group");
myStatBx.orientation = "column";
myStatBx.add("statictext", undefined, " pt");
myStatBx.add("statictext", undefined, " %");
var b = w.add ("group");
b.add ("button", undefined, "OK", {name: "ok"});
b.add ("button", undefined, "Anuluj", {name: "cancel"});
if (w.show() == 1)
return [Ch1.value, Ed1.text, Ch2.value, Ed2.text];
else exit();
}
function mShrink (textFr, ToDoArr) { // input textFrame and array with mDialog result
var pSizeLimAc, pSizeLim, pSizeCurr, pSizeDiff, pSizeStepN, pSizeStep,
hScaleAc, hScaleLim, hScaleCurr, hScaleDiff, hScaleStepN, hScaleStep,
ToDo;
pSizeLimAc = ToDoArr[0];
hScaleAc = ToDoArr[2];
pSizeLim = ToDoArr[1];
if (pSizeLimAc) {
if (isNaN (parseFloat(pSizeLim) ) ) return [false, "point size is not a number"];
else pSizeLim = parseFloat(pSizeLim);
pSizeCurr = textFr.parentStory.pointSize;
pSizeDiff = pSizeCurr - pSizeLim;
pSizeStepN = pSizeDiff / 0.1;
pSizeStep = 0.1;
}
hScaleLim = ToDoArr[3];
if (hScaleAc) {
if (isNaN (parseFloat(hScaleLim) ) ) return [false, "hori scale is not a number"];
else hScaleLim = parseFloat(hScaleLim);
hScaleCurr = textFr.parentStory.horizontalScale;
hScaleDiff = hScaleCurr - hScaleLim;
if (pSizeLimAc) hScaleStepN = pSizeStepN;
else hScaleStepN = hScaleDiff;
hScaleStep = Math.round(hScaleDiff/hScaleStepN*10)/10;
}
if (!(hScaleDiff > 0) ) hScaleAc = false;
if (!(pSizeDiff > 0) ) pSizeLimAc = false;
if (pSizeLimAc && hScaleAc) ToDo = 3;
else if (pSizeLimAc) ToDo = 1;
else if (hScaleAc) ToDo = 2;
else ToDo = 0;
switch (ToDo) {
case 1: {
while (pSizeStepN-- && textFr.overflows)
textFr.parentStory.pointSize -= pSizeStep;
break; }
case 2: {
while (hScaleStepN-- && textFr.overflows)
textFr.parentStory.horizontalScale -= hScaleStep;
break; }
case 3: {
while (hScaleStepN-- && textFr.overflows)
{
textFr.parentStory.pointSize -= pSizeStep;
textFr.parentStory.horizontalScale -= hScaleStep;
}
break; }
default: break;
}
if (textFr.overflows) mFramesToMove.push(textFr);
return [true];
}
User will be asked for pointSize and horizontalScale lower limit.
rgds
Copy link to clipboard
Copied
OMG! You are a god among men sir! I create bulk labels in indesign and there are obvious size constraints. I just used this script and it sized 19 pages of over-set text with a click of a button and looks beautiful! You have just saved me soooooooo much time in my process of creating these labels.
Copy link to clipboard
Copied
This is brilliant. Thank you.
Copy link to clipboard
Copied
You are the best!
Copy link to clipboard
Copied
wow this script is fantastic, but does anyone know how to make it horizontally scale the text by automatically applying just the amount of scaling which would make the text fit into the frame, in other words, without setting any limit and let the script decide which is the correct value ? I've got a very long document with hundreds of frames that need scaling, each one with different values and I must not modify the frames in any way. ![]()
thank you! ![]()
Copy link to clipboard
Copied
You could check out our Fit Text to Frame: http://www.id-extras.com/products/fit-text-to-frame (free for 30 days).
Copy link to clipboard
Copied
Hi this script is an incredible script, I work for a company that supplies name badges and almost 20% of the time the names are overset. My only enquiries are can the script be adjusted to not ask for a limit and simply kern until fit, and is there a way to make this work for multiple line text within the same frame. Thanks! ![]()
Copy link to clipboard
Copied
Hi, would someone mind explaining how to actually create this script? I have copy and pasted it into Textedit, added the extension .jsx and put it in the appropriate scripts folder. When I double click it, it's coming up with an error - I'm no script expert but every day is a school day! ![]()
Copy link to clipboard
Copied
Ah I figured it out - don't copy the numbers!
Copy link to clipboard
Copied
This is a real simple script that will loop through all the text frames of the document and if the text overflows (overset text) will reduce the point size of the font by 1 until it no longer oversets.
var doc = app.activeDocument;
for(var i = 0; i < doc.textFrames.length; i++) {
while(doc.textFrames.item(i).overflows) {
var fontSize = doc.textFrames.item(i).paragraphs.item(0).pointSize;
doc.textFrames.item(i).paragraphs.item(0).pointSize = fontSize-1;
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now