6 Replies Latest reply on Aug 21, 2013 12:48 AM by ThorneyBay

    Script to make text frame or table cell hit precise depth - ID5.5

    ThorneyBay

      Is there a script out there which can make a text frame or maybe a table cell adjust to a fixed depth of a centimetre. ie 6cm or 7cm when filled with text?

        • 1. Re: Script to make text frame or table cell hit precise depth - ID5.5
          DaveSofTypefi Level 2

          Each time I look at this question the thought rattles around my head: why not just make it that size in the first place?

           

          You can certainly force a text frame to a particular height easily enough (assuming no rotation):

           

          myBounds = myFrame.geometricBounds;

          myBounds[2] = myBounds[0] + myHeight;

          myFrame.geometricBounds = myBounds;

           

          For a cell, it's even easier:

           

          myCell.autoGrow = false;

          myCell.height = myHeight;

           

          Or is your question about detecting the event that text has been typed into the object and you're looking for how to trigger a script on occurrence of such an event?

           

          Dave

          • 2. Re: Script to make text frame or table cell hit precise depth - ID5.5
            ThorneyBay Level 1

            Thanks Dave

            We are looking at a trigger. Different amount of text means different height means that the height is never known until text is entered. Text will come in with style sheets but the depth that will be required will need to be precise that is to a cm depth. If text frame naturally finishes at 5.7cm it will need to be adjusted  to 6cm deep. All adverts inserted into newspapers need to be a specific cm depth. A script that can achieve this will make a lot of people happy.

            • 3. Re: Script to make text frame or table cell hit precise depth - ID5.5
              Vamitul Level 4

              that is the easiest thing.

              myCell.height will give you the current cell height (for example 51.477). so..

              myCell.height=Math.ceil(myCell.height);  //wil make it 52 (i use mm as measurement units. if you need cm, best thing to do (to make it indepenedent is to use the UnitValue class).

              • 4. Re: Script to make text frame or table cell hit precise depth - ID5.5
                ThorneyBay Level 1

                Hi Vamitul

                I am greatly encouraged by the fact that this is easy. However because I am afraid I know less than anything about scripts I wonder if I could have just a little more information. Would what you have described above be a java script? Would I be asking too much for you to attach the above as a script? Millimetres as measurement would be great. Cell height would indicate a table cell, could that not also be substituted by text frame? Many thanks in advance

                • 5. Re: Script to make text frame or table cell hit precise depth - ID5.5
                  Vamitul Level 4

                  Hi!

                   

                  For text frames things are a bit more tricky as they don't have a height property, so you will have to devise that from the geometric bounds. Right now i am insanely busy, but if you give me a lot more information i will try to help you as soon as i get some free time.

                  Do you need the script to run on all the cells in all the tables in the document, or just in some selected ones? the same for text frames.

                  • 6. Re: Script to make text frame or table cell hit precise depth - ID5.5
                    ThorneyBay Level 1

                    Hi Vamitul

                    You are an insanely busy prince or princess as the case may be.

                    What this script will be of use for, will be adverts that appear in newspapers. They are many and varied but all adds that appear in newspapers must fit to precise depths ie 80mm deep, 150mm deep etc etc. The reason I threw in a table cell is because the ad could be constructed in a single table cell. We have small legal ads that have a rule top and bottom, it would be possible to create the ad as a single table cell rather than as a text frame with rules drawn at the top and bottom. However there would be far more application for the script if it could be applied to text frames. A single text frame with border is one that possibly the simplest and we have plenty of those. The furthest point maybe to go, would be a grouped collection of shapes, picture frames and text frames that make up the advert and need to be the precise depth. These individual adverts are normally one document, on rare occasions they may stretch over more than one page. I hope you haven't regetted too much in asking for more information but if you are successfully I will be insanely happy.

                     

                    Many thanks Steve