10 Replies Latest reply on Aug 18, 2016 9:42 PM by studioo14035488

    Script for shrinking overset text?

    SatchBoogie1 Level 1

      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%)?

        • 1. Re: Script for shrinking overset text?
          Colin Flashman Adobe Community Professional

          I think the answer was in an earlier post: http://forums.adobe.com/message/4763303


          In short, it is one of two answers:


          1. If the desired result is to expand the frame, this can be accomplished in cs6 using Persistent text frame fitting options.
          2. If the desired result is to change the size of the text without any input, there's a trick with GREP styles that I wrote about on my blog, along with a download of a pdf/indd of how it was done. http://colecandoo.wordpress.com/2012/02/18/square-pegs-now-fit-into-round-holes/



          • 2. Re: Script for shrinking overset text?
            SatchBoogie1 Level 1

            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.

            • 3. Re: Script for shrinking overset text?
              Colin Flashman Adobe Community Professional

              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/

              • 4. Re: Script for shrinking overset text?
                Jump_Over Level 5



                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[k].constructor.name == "TextFrame" && myPit[k].overflows )
                    textArr.push(myPit[k]);    // 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[i], 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");
                            mLayer = myDoc.layers.add({LocationOptions: LocationOptions.AT_BEGINNING, name: "Overset frames"});
                        for (var i = 0; i < mFramesToMove.length; i++)
                        mFramesToMove[i].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,
                    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.


                1 person found this helpful
                • 5. Re: Script for shrinking overset text?

                  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.

                  • 6. Re: Script for shrinking overset text?
                    Simon Ed Hanna Level 1

                    This is brilliant. Thank you.

                    • 7. Re: Script for shrinking overset text?
                      Doctor__Rock Level 1

                      You are the best!

                      • 8. Re: Script for shrinking overset text?
                        cinzia_pn Level 1

                        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!

                        • 9. Re: Script for shrinking overset text?
                          TᴀW Adobe Community Professional & MVP

                          You could check out our Fit Text to Frame: http://www.id-extras.com/products/fit-text-to-frame (free for 30 days).

                          • 10. Re: Script for shrinking overset text?
                            studioo14035488 Level 1

                            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!