Script for shrinking overset text?

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

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[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");
        else
            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,
        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

Similar Messages

  • Script for export all text in single rtf file?

    Hi!
    I need to export all storys from indd document to a single rtf file. Is there avaible some free script for CS4 which can do that?

    if(app.documents.length != 0){
         if(app.documents.item(0).stories.length != 0){
              myGetFileName(app.documents.item(0).name);
    //========================= FUNCTIONS ===========================
    function myGetFileName(myDocumentName){
         var myFilePath = File.saveDialog("Save Exported File As:");
         if(myFilePath != null){
              myDisplayDialog(myDocumentName, myFilePath);
    function myDisplayDialog(myDocumentName, myFilePath){
         //Need to get export format, story separator.
         var myExportFormats = ["Text Only", "Tagged Text", "RTF"];
         var myDialog = app.dialogs.add({name:"ExportAllStories"});
         with(myDialog.dialogColumns.add()){
              with(dialogRows.add()){
                   with(dialogColumns.add()){
                        var myExportFormatDropdown = dropdowns.add({stringList:myExportFormats, selectedIndex:0});
              with(dialogRows.add()){
                   var myAddSeparatorCheckbox = checkboxControls.add({staticLabel:"Add separator line", checkedState:true});
         var myResult = myDialog.show();
         if(myResult == true){
              var myExportFormat = myExportFormats[myExportFormatDropdown.selectedIndex];
              var myAddSeparator = myAddSeparatorCheckbox.checkedState;
              myDialog.destroy();
              myExportAllText(myDocumentName, myFilePath, myExportFormat, myAddSeparator);
         else{
              myDialog.destroy();
    function myExportAllText(myDocumentName, myFilePath, myExportFormat, myAddSeparator){
         var myPage, myStory;
         var myExportedStories = [];
         var myTempFolder = Folder.temp;
         var myTempFile = File(myTempFolder + "/tempTextFile.txt");
         var myNewDocument = app.documents.add();
         var myDocument = app.documents.item(myDocumentName);
         var myTextFrame = myNewDocument.pages.item(0).textFrames.add({geometricBounds:myGetBounds(myNewDocument, myNewDocument.pages.item(0))});
         var myNewStory = myTextFrame.parentStory;
         for (var i = 0; i < myDocument.pages.length; i++) {
              myPage = myDocument.pages.item(i);
              for (var t = 0; t < myPage.textFrames.length; t++){
                   myStory = myPage.textFrames[t].parentStory;
                   if (!IsInArray(myStory.id, myExportedStories)) {
                        //Export the story as tagged text.
                        myStory.exportFile(ExportFormat.taggedText, myTempFile);
                        myExportedStories.push(myStory.id);
                        //Import (place) the file at the end of the temporary story.
                        myNewStory.insertionPoints.item(-1).place(myTempFile);
                        //If the imported text did not end with a return, enter a return
                        //to keep the stories from running together.
                        if(i != myDocument.stories.length -1){
                             if(myNewStory.characters.item(-1).contents != "\r"){
                                  myNewStory.insertionPoints.item(-1).contents = "\r";
                             if(myAddSeparator == true){
                                  myNewStory.insertionPoints.item(-1).contents = "----------------------------------------\r";
                   } // if not exported
              } // for text frames
         } // for pages
         switch(myExportFormat){
              case "Text Only":
                   myFormat = ExportFormat.textType;
                   myExtension = ".txt"
                   break;
              case "RTF":
                   myFormat = ExportFormat.RTF;
                   myExtension = ".rtf"
                   break;
              case "Tagged Text":
                   myFormat = ExportFormat.taggedText;
                   myExtension = ".txt"
                   break;
         myNewStory.exportFile(myFormat, File(myFilePath));
         myNewDocument.close(SaveOptions.no);
         myTempFile.remove();
    function myGetBounds(myDocument, myPage){
         var myPageWidth = myDocument.documentPreferences.pageWidth;
         var myPageHeight = myDocument.documentPreferences.pageHeight
         if(myPage.side == PageSideOptions.leftHand){
              var myX2 = myPage.marginPreferences.left;
              var myX1 = myPage.marginPreferences.right;
         else{
              var myX1 = myPage.marginPreferences.left;
              var myX2 = myPage.marginPreferences.right;
         var myY1 = myPage.marginPreferences.top;
         var myX2 = myPageWidth - myX2;
         var myY2 = myPageHeight - myPage.marginPreferences.bottom;
         return [myY1, myX1, myY2, myX2];
    function IsInArray(myString, myArray) {
         for (x in myArray) {
              if (myString == myArray[x]) {
                   return true;
         return false;
    This is a revised version of the script --  not totally tested.
    Kasyan

  • Indesign CS3 what script for Break Out Text Frame ??

    hi expert,
    Indesign CS3 can Break Out Text Frame or Have Script ??
    like this...
    http://img402.imageshack.us/img402/905/20080517085017hb3.jpg
    thank for tell

    you mean - convert/split multicolumn TextFrame to separated TextFrames ?
    for PC or MAC ?
    robin
    www.adobescripts.com

  • Creating a script for a repeating text input on Flash game

    Hey there, I play a browser-based Flash game (in Google Chrome) and one of the most time-consuming aspects of the game is repeating text inputs within the game. This repeat will be inputting a number, followed by tab - tab and then another number and so on. I am a complete novice when it comes to things like this. Many of my gaming friends on Windows have set up macros that enable a hotkey to input all the text in all the fields. I would love to do the same, but have no idea how.
    Is this possible? I apologise for being a total noob on this. Applescript and automator has me completely baffled.

    You can backup using some unix shell scripts.
    rman is not really good one.

  • Overset text warning

    Quick question about this dialog box. If I get an overset text warning and I check "Don't show again," does that apply only to the current document or to all future documents?
    I know I can reset the dialog box if I disable it, but what I'd like to happen is that I'm warned the first time and then no longer for each document. There are some documents I print where I know there will be overset text, but others where I don't want to miss it.
    If anyone knows for sure which way it rolls I'd appreciate it. Thanks.
    --T.

    Peter and Peter,
    I'm afraid that this script has a bug in it. The length property of an associative array is only non-zero if one or more of the names can be interpreted as a number.
    So, running the script with two overset text frames on page 1, the script works if I have no section marker associated with page 1, but if I put in a section marker [Edit: I meant section prefix] that isn't a number, the script fails to find the overset frames because the length in that case is still zero.
    I stumbled on this while trying to use these arrays to assemble an index from a spreadsheet. My entries were the names of the indexed items and I couldn't work out why (a) my array was showing a length of zero yet (b) Peter's script seemed to work.
    So, the question is, what is the safe way to determine whether or not an associative array is populated when you don't know the names of any of the elements?
    And right now, I'm stumped on that, so I'll throw the question open to anyone who knows.
    Dave

  • Overset text check or warning or something

    hi
    is there a way where u can check all your document for overset text, like a shortcut or during preflight or something? i use indesign CS2
    thanks

    Peter and Peter,
    I'm afraid that this script has a bug in it. The length property of an associative array is only non-zero if one or more of the names can be interpreted as a number.
    So, running the script with two overset text frames on page 1, the script works if I have no section marker associated with page 1, but if I put in a section marker [Edit: I meant section prefix] that isn't a number, the script fails to find the overset frames because the length in that case is still zero.
    I stumbled on this while trying to use these arrays to assemble an index from a spreadsheet. My entries were the names of the indexed items and I couldn't work out why (a) my array was showing a length of zero yet (b) Peter's script seemed to work.
    So, the question is, what is the safe way to determine whether or not an associative array is populated when you don't know the names of any of the elements?
    And right now, I'm stumped on that, so I'll throw the question open to anyone who knows.
    Dave

  • How to autoflow overset text in script?

    Gurus,
    I write a script to import xml and place it in text frame but I had my overset text, i know that it just a shift+doubleclick in outport of text frame to autoflow text, the problem is how can i write it in a script? please help! Thanks in advance!

    You need to add the frames and thread them yourself. Search the forum
    for past discussions. you should find sample code to do that.
    Harbs
    http://www.in-tools.com

  • Overset text will not go into the text box that is part of the master for the next page

    I am trying to (first time user) set up a simple trade-paperback sized book with some photos.  Have set up several masters for chapter title pages, chapter inner pages, etc.  When I copy text out of Word into InDesign, (copy/paste) the text overset box appears.  I load it, then go to the next page, which I have already formatted using one of the masters.  But when I select the desired text box ((Ctrl/shft) and click, the overset text forms a new text box, What am I doing wrong? thanks

    I have done, this did work right for at least the left side of the spread, but never for the right side -
    Make sure the left and right page master page text frames are threaded View>Extras>Show Text Threads. Here I have left and right page text boxes threaded on my A-master spread:
    Checking Smart Text Reflow can make adding long text to master frames easier:
    With Smart Text Reflow enabled I've released the  master page text box on page 1, note the released frame has a solid border, while the unreleased master page frames on subsequent pages are dotted indicating they are still master page items and not page items.
    The result of the paste:

  • SAP VB script for updating texts in purchase orders

    Hello,
    I am trying to create a SAP script for updating texts in purchase orders. It is in the last third - Item Detail,  Texts tab.
    The script is ok apart from the fact that it always deletes whatever text is in there and than add a new one.
    I would like to keep history in the texts tab and always just add one line to existing texts. Is there any way (command) how
    to keep existing texts and only add a new line to the top?
    Thanks a lot!
    Jan

    Yes, you are exactly right. I have already figured it out as well. I did not expect it would be that easy. But thanks a lot anyway for replying on this!
    Now I am struggeling with changing SAPLMEGUI in vb scripts for ME22n. Sometimes, there is SAPLMEGUI:0010 and sometimes SAPLMEGUI:0015. Even when the users have the same screens in the beginning the SAPLMEGUI number differs. They also do one item by hand and than it changes. It keeps changing between SAPLMEGUI:0010 and SAPLMEGUI:0015
    Is there a way how to have the same number of SAPLMEGUI or how to eliminate this issue?
    Thanks a lot
    Jan

  • I am in need of ai script for arcing text

    i am in need of ai script for arcing text

    A little vague aren't we… Is this the kind of arcing you mean? Text along a curve or do you mean distorting into an arch like some plug-in can?
    #target illustrator
    var doc = app.activeDocument;
    doc.defaultFilled = false, doc.defaultStroked = true;
    var textPath = doc.pathItems.ellipse( 0, 0, doc.width, doc.height );
    textPath.pathPoints[3].selected = PathPointSelection.ANCHORPOINT;
    app.cut();
    doc.selection = null;
    app.redraw();
    var tp = doc.textFrames.pathText( doc.pathItems[0], 0, 0, TextOrientation.HORIZONTAL );
    tp.textRange.paragraphAttributes.justification = Justification.CENTER;
    tp.textRange.characterAttributes.size = 60;
    tp.contents = 'I am in need of ai script…';
    var tpd = tp.duplicate();
    tpd.translate( 0, -150 );
    tpd.textRange.characterAttributes.size = 90;
    tpd.contents = '…for arcing text?';

  • Script for search TextFrame whitout full text, and top align...

    This script "JUSTIFY_ALING" all text frames without footnotes:
    var TRUFI = app.activeDocument.textFrames.everyItem().getElements(),
         CHARLY;
    while( CHARLY=TRUFI.pop() )
         if ( CHARLY.footnotes.length == 0)
              CHARLY.textFramePreferences.verticalJustification = VerticalJustification.JUSTIFY_ALIGN;
    But I need that TextFrames whitout full text (for example: the text only go to the middle of the textframe) stay in TOP_ALIGN...
    Thanks for read me... 

    You can't tell right away if a textframe is filled all the way to the bottom. Even with linked text threads, there is usually a small space at the bottom, just not enough for an entire next line -- less than the leading of that next line. There may even be more space at the bottom, if the next frame starts with a heading, which is kept with a number of lines following it; or a large inline table or figure; or a hard page break. Or (come to think of it) a footnote -- I'm not sure what would happen then ...
    But you can get the vertical position of the last regular text line. With a text frame selected:
    alert (app.selection[0].lines.item(-1).baseline);
    will show you the absolute vertical position of that last line. If you need the distance from the top of its containing text frame, use
    alert (app.selection[0].lines.item(-1).baseline - app.selection[0].geometricBounds[0]);
    -- you might remember that the array 'geometricBounds' contains the positions of top, left, bottom, and right corners, in that order. So geometricBounds[0] is the top y position; subtract this from your baseline, and you know how low you go.
    In this case, you would want the distance from the last line to the bottom:
    alert (app.selection[0].geometricBounds[2] - app.selection[0].lines.item(-1).baseline) ;
    w
    will show you how much space there is left. A warning is in place: blank lines are also lines! (Theoretically, if this happens a lot, you could adjust for these. Left as an exercise.)
    All you have to do is ask yourself, what amount of white space at the bottom is allowed? Then check your frames for this, and only apply vertical justification if it's inside your parameters.
    (Apologies for those weirdly cramped final paragraphs. Sorry -- tried to restore it to normal readability, failed miserably. Jive Strikes Again!)

  • A script for replacing texts only in selected layer?

    Hi all,
    I have an illustrator document which has many text layers. I have found the script below that replace a text with another one in the document;
    var doc = app.activeDocument;
    var myTextFrames = doc.textFrames;
    for (i = 0; i < myTextFrames.length; i++) {
    var myTF_ByI = myTextFrames[i];
    var str = myTF_ByI.contents
    var res = str.replace("word1", "word2");
    myTF_ByI.contents = res
    However, there is one problem that the script also replaces the text in other layers even though they are hidden or locked. Could you help me adjust this script to be effective only for the selected or unhidden layer?
    Cheers,
    Akin

    Hi elmagnifico,
    this is strange.
    Before running the script snippet:
    and after running the snippet:
    Can you show us your layers palette? Do you really layers mean – and not sublayers or not simple text items in one layer???
    regards

  • How to make a script for find text object?

    Hi everyone
    I want to make a script for find and select text object and then find next, find next, and so on, but without any open dialog
    Is that possible make a script for this?
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "(\[\x{2022}\])|(\x{25CF})";
    app.findGrep();
    thanks
    Regard

    You already have that. A script does not 'find, select, find next' - it finds all texts as soon as you execute the 'app.findGrep' command.

  • Syntax for identifying Area Text which has overset text

    Is there a way to identify if the Area Text box has overset text using Applescript? if yes, can some one let me know the syntax please.
    Thanks in advance
    Jaim

    Hey Carlos,
    Thanks for pointing me to the right post which has given me some solution. Though there is no direct method, solution given in the post really helped me out.
    set testLength to length of lines of text frame 1 of document 1
    Above AS statement will only count characters that are visible, this does not include overflowed characters.
    Thanks to Ten A for the work around.
    Thanks to Carlos for pointing me to the right post
    Best Regards
    jaim

  • Default gutter width for drawing text boxes for overset text

    I have master pages that were created with columns and the correct gutter width we want. When I drag a story from a window (a window that is part of our CMS) and place it on the page, the gutters between the text columns are correct -- p9 (or 0.125 inches). But if I draw a new text box or if I click the red plus to draw a text box for overset text, the gutter is a full pica (or 0.1667 inches).
    I want any text box that is drawn on the page or any overset text box that is drawn to default to p9 for gutters.
    I don't want to manually change the gutter for every new text box I draw.
    I'm using ID with CS4.
    Thank you.

    The default gutter in a multi-column frame is set in the object style under Text Frame General Options. If you haven't defined any new styles you only need to edit the [Basic Text Frame] style. New frames will use the new gutter value when you add columns. If you have object styles for other text frames, you'll need to edit those, too. For existing frames, if the number of columns has been changed manually, you will need to reset the gutter.

Maybe you are looking for