8 Replies Latest reply on Feb 29, 2008 9:38 PM by (pasupathy)

    Fit content to a two columns frame

      Hi Experts,

      I need to fit content in to frame (it is a double column). But I can't see any feature in scripting. Manually also I can see fit option only for single column frame. Please advice me.

      thanks,
      Pasu
        • 1. Re: Fit content to a two columns frame
          [Jongware] Most Valuable Participant
          Fit content to frame -- you would want the text to size to fit a frame? As that's not an option for text in the UI, I presume you mean the other way around -- fit frame to content.

          But it's quite interesting, I, for one, didn't know this until I tried. You
          i cannot
          fit frame to content if you have multiple text columns. The option disappears from the context menu, and is grayed out in the Object menu. Well, that's pretty conclusive -- you can't do this.

          By the way: you are unclear about what "feature" you can't see in scripting. If you mean you can't find "Fit content to double column frame", well, there are lots of vaguely described actions that aren't in scripting. OTOH, just about every physical object has a method 'fit', which uses a FitOptions enumeration -- the very same list from the UI. The fact that it does not work on 2 column frames is something else.
          • 2. Re: Fit content to a two columns frame
            Kasyan Servetsky Level 5
            Hi Pasu,
            Here is a workaround for multicolumn text frames. I assume that active document has only one text frame and ruler units are set to millimeters.
            //--------------------------------
            var myDoc = app.activeDocument;
            myTextframe = myDoc.textFrames[0];

            while (myTextframe.overflows){
            var myBounds = myTextframe.geometricBounds;
            myBounds[2] += 1;
            myTextframe.geometricBounds = myBounds;
            }
            //--------------------------------
            Kasyan
            • 3. Re: Fit content to a two columns frame
              Level 1
              Hi Kasyan,

              Thanks for your reply.

              I am not facing overflow problem. I have two columns textframe in which in one column contains full text and the other one contains partial text. Now I need to fit and make it equally distributed textframe. Can you please tell me your suggestion?

              thanks,
              Pasu
              • 4. Re: Fit content to a two columns frame
                [Jongware] Most Valuable Participant
                Well, that's a bit clearer. How about this -- building on Kasyan's script. The debugging alerts at the start show what properties to check. It fails
                i spectacularly
                if you try this on non-standard frames, f.e., if you put a text wrapping image over part of the first column :-)

                myTextframe = app.selection[0];

                numlines = myTextframe.lines.count();
                alert ("Total: "+numlines);
                numlines_1 = myTextframe.textColumns[0].lines.count();
                alert ("1st column: "+numlines_1);

                if (myTextframe.textColumns[0].lines.count() < myTextframe.textColumns[1].lines.count())
                {
                while (myTextframe.textColumns[0].lines.count() < myTextframe.textColumns[1].lines.count())
                {
                var myBounds = myTextframe.geometricBounds;
                myBounds[2] += 1;
                myTextframe.geometricBounds = myBounds;
                }
                } else
                {
                while (myTextframe.textColumns[0].lines.count() > myTextframe.textColumns[1].lines.count())
                {
                var myBounds = myTextframe.geometricBounds;
                myBounds[2] -= 1;
                myTextframe.geometricBounds = myBounds;
                if (myTextframe.overflows)
                {
                myBounds[2] += 1;
                myTextframe.geometricBounds = myBounds;
                break;
                }
                }
                }
                • 5. Re: Fit content to a two columns frame
                  [Jongware] Most Valuable Participant
                  Hah -- Scratch that previous post. Kasyan's idea works much better, provided you check first for not-overflows, then for overlflows. That way you can run it on just about any text frame you have, any number of columns, etc.

                  It boils down to

                  myTextframe = app.selection[0];
                  while (myTextframe.overflows == false)
                  {
                  var myBounds = myTextframe.geometricBounds;
                  myBounds[2] -= 1;
                  myTextframe.geometricBounds = myBounds;
                  }
                  while (myTextframe.overflows == true)
                  {
                  var myBounds = myTextframe.geometricBounds;
                  myBounds[2] += 1;
                  myTextframe.geometricBounds = myBounds;
                  }
                  • 6. Re: Fit content to a two columns frame
                    Kasyan Servetsky Level 5
                    Hi jongware,

                    You are reading my thoughts I was going to post the same code.

                    Kasyan
                    • 7. Re: Fit content to a two columns frame
                      [Jongware] Most Valuable Participant
                      "Great minds ..." ;-)

                      It works a treat, even on a full page of text with all sorts of images on top and lots of columns. I ran it a few times with larger and smaller images, just because it's fun to look at!
                      • 8. Re: Fit content to a two columns frame
                        Level 1
                        Hi,

                        Thank you very much.

                        thanks,
                        Pasu