6 Replies Latest reply on Feb 11, 2013 4:56 AM by SureshRaji

    Justification in Indesign CS6

    Sudha K Level 1

      Hi,

       

         I want to do justification in Indesign CS6.  When im trying its throwing the error 'data out of range'.  My code is

       

       

      var myDoc = app.activeDocument;

      myParagraphs = myDoc.paragraphStyles;

       

       

       

      for(var i=1; i<myParagraphs.length; i++)

      {   

       

                  myParagraphs[i].minimumWordSpacing = 25;

                  myParagraphs[i].desiredWordSpacing = 30;

                  myParagraphs[i].maximumWordSpacing = 50;

                  myParagraphs[i].minimumLetterSpacing = 25;

                  myParagraphs[i].desiredLetterSpacing = 40;

                  myParagraphs[i].maximumLetterSpacing = 75;

                  myParagraphs[i].minimumGlyphScaling = 25;

                  myParagraphs[i].desiredGlyphScaling = 50;

                  myParagraphs[i].maximumGlyphScaling = 100;

      }

       

      Kindly help me.

        • 1. Re: Justification in Indesign CS6
          Vamitul Level 4

          GlyphScaling cannot be lower than 50.

           

          myParagraphs[i].minimumGlyphScaling = 25 // imposible indesign hard-coded lower limit is 50 ;

          1 person found this helpful
          • 2. Re: Justification in Indesign CS6
            Sudha K Level 1

            Hi thanks for your replay.

            Now It is working fine for glyphs, but not for letterspacing.

             

            I tried folowing code with the below specified limits, but it is showing error     -   " data out of range"

             

            Kindly help me on this.

             

             

            var myDoc = app.activeDocument;

            myParagraphs = myDoc.paragraphStyles;

             

            for(var i=1; i<myParagraphs.length; i++)

            myParagraphs[i].minimumLetterSpacing = parseInt (myPointSizeField4.editValue);  // 100 to 500

            myParagraphs[i].desiredLetterSpacing = parseInt (myPointSizeField5.editValue);   // 100 to 500

            myParagraphs[i].maximumLetterSpacing = parseInt (myPointSizeField6.editValue);   // 100 to 500

            }

            • 3. Re: Justification in Indesign CS6
              Vamitul Level 4

              oh man.. i had such a nice and detailed replay just before the forums went down.. here we go again

              it is the same problem as before

              here are the minumum/maximum values (in CS5, but i'm guessing they are the same in CS6):

               


              Min. valueMax. value
              Word Spacing01000
              Letter Spacing-100500
              Glyph Scaling50200

               

               

              what kind of object is myPointSizeField4? Form what I see you are using plain widget scripting (don't know how to call it as opposed to ScriptUI objects). Be careful with the Editboxes as they convert the user's input into points!

               

              for debugging purposes try sprinkling your code with some alerts, in this case, just before trying to change the paragraph styles:

              alert ("myPointSizeField4 value is: "+parseInt (myPointSizeField4.editValue).toString());

               

              also there is a small problem with your code, as myDoc.paragraphStyles will return only the first level of them (the "myParagraphs" variable will not contain the paragraphs styles that are in groups/subgroups). better for you is:

              var myDoc = app.activeDocument;

              var myParagraphs = myDoc.allParagraphStyles; // use var to declare variables. not compulsory in javaScript, but will save you a lot of troube in the long run; the allParagraphStyles property returns a proper array (not a collection), and will include all paragraphs styles regardless of whether tey are inside groups or not.

              • 4. Re: Justification in Indesign CS6
                Sudha K Level 1

                Hi,

                     I tried as you said , still it is showing error as below.

                 

                var myDoc = app.activeDocument;

                //myParagraphs = myDoc.paragraphStyles;

                 

                myParagraphs = myDoc.allParagraphStyles;

                 

                for(var i=1; i<myParagraphs.length; i++)

                {

                myParagraphs[i].minimumLetterSpacing = parseInt (myPointSizeField4.editValue).toString();    // value = 10

                myParagraphs[i].desiredLetterSpacing = parseInt (myPointSizeField5.editValue).toString();    // value = 20
                myParagraphs[i].maximumLetterSpacing = parseInt (myPointSizeField6.editValue).toString();   // value = 30

                }

                 

                 

                When I used toString I got following error message

                 

                Screen shot 2012-12-29 at 9.53.50 AM.png

                 

                 

                when I dont use toString() i got below error

                 

                Screen shot 2012-12-29 at 9.53.18 AM.png

                 

                 

                dono what to do.

                • 5. Re: Justification in Indesign CS6
                  Sudha K Level 1

                  Hi,

                   

                    I got solution for my prob. Using properties, i can do this. 

                   

                    Thanks.

                   

                  - Sudha K

                  • 6. Re: Justification in Indesign CS6
                    SureshRaji Level 2

                    Hi,

                     

                    The default justification values for a default document is:

                     

                    Word Spacing : 80, 100, 133

                     

                    Letter Spacing : 0, 0, 0

                     

                    Glyph Scaling : 100, 100, 100

                     

                    So, we have to set the maximum letter spacing at first, then desired letter spacing and then minimum letter spacing accordingly. The same is also applied for Glyph Scaling also.

                     

                     

                    Try like this,

                     

                    myParagraphs[i].maximumLetterSpacing = 75;

                    myParagraphs[i].desiredLetterSpacing = 40;

                    myParagraphs[i].minimumLetterSpacing = 25;

                     

                     

                     

                    Hope this may be helpful.