7 Replies Latest reply on Oct 20, 2012 9:35 PM by lithodora

    [AS] Set every character leading to auto


      I can't seem to get this to do what I expect.


      tell application "Adobe InDesign CS5.5"

      tell every text frame of page 1 of active document

        set leading of properties of every character of every paragraph to auto

      end tell

      end tell



      The script I am working on imports text. Everything works except the leading, it comes in with "0 pt" leading and I need the script to basically check every character on the page and if the leading is 0 set it to auto.... I put this together as a quick and dirty test to try and make it work and in no way represents the final code.


      Everything I have tried has either done nothing or gives me an error saying "Expected number, string or auto" when I give it auto.



      I don't care if it is AS or JS as long as it works.

        • 1. Re: [AS] Set every character leading to auto
          Jump_Over Level 5



          If it could be [JS], so


          app.activeDocument.pages[0].textFrames.everyItem().characters.everyItem().leading = Leading.AUTO;


          should work

          • 2. Re: [AS] Set every character leading to auto
            L. Guy O'Rojo Level 2

            In CS4 you could:


            tell application "Adobe InDesign CS4"

                      tell document 1

                                tell text frame 1

                                          tell parent story

                                                    set leading to auto

                                          end tell

                                end tell

                      end tell

            end tell

            1 person found this helpful
            • 3. Re: [AS] Set every character leading to auto
              lithodora Level 1

              Since I had need of it not changing every letter I ended up using the following:


              tell application "Adobe InDesign CS5.5"

              do script "

              var letters = app.activeDocument.pages[0].textFrames.everyItem().characters.length;


              for (var i=0;i<letters;i++)


              if(app.activeDocument.pages[0].textFrames.everyItem().characters[i].leading == 0){

                  app.activeDocument.pages[0].textFrames.everyItem().characters[i].leading = Leading.AUTO;




              " language javascript


              end tell

              • 4. Re: [AS] Set every character leading to auto
                lithodora Level 1

                While this works great in CS4 running this exact code in CS5.5 gives the error:


                Expected number, string or auto




                • 5. Re: [AS] Set every character leading to auto
                  Peter Kahrel Adobe Community Professional & MVP

                  Instead of iterating over letters, simply use this:


                  app.activeDocument.pages[0].textFrames.everyItem().characters.everyItem().leading = Leading.AUTO


                  If you still have problems with that " Expected number, string or auto" error, try the numerical value:


                  app.activeDocument.pages[0].textFrames.everyItem().characters.everyItem().leading = 1635019116


                  But surely you can formulate this in AppleScript, can't you? But anyway, if you want to use the JavaScript code, there's no need to use doSctipt, as JavaScripts run natively on Macs.



                  • 6. Re: [AS] Set every character leading to auto
                    Muppet Mark Level 5

                    tell application "Adobe InDesign CS5"

                              tell document 1

                                        tell page 1

                                                  tell parent story of every text frame

                                                            set leading to auto

                                                  end tell

                                        end tell

                              end tell

                    end tell

                    • 7. Re: [AS] Set every character leading to auto
                      lithodora Level 1

                      The problem is that some text comes in with the leading set properly and some doesn't. Only when the leading is set to 0 should it adjust it to auto.


                      I also need the 'do script' because this is a single line in a very large script written almost entirely in Applescript.


                      The project I am working on takes documents made in MultiAd Creator and migrates them to Indesign. We are phasing out the other product and using only Adobe. The entire archive of old documents needs to be migrated over to indesign.

                      The script currently will get about 80% of that correct. The leading was one of the minor issues. There is something like 4000 documents to be migrated over and the script needs to pretty much do it without interaction and get the new document to be 100% exact to the old document.


                      It works like this:

                      The script navigates the entire server finding Creator documents.

                      Opens each in turn in Creator.

                      Creates a new InDesign document of the same dimensions.

                      Every color in the Creator document is add to the swatches in InDesign.

                      Then every shape object is recreated point by point in the InDesign document. (this includes the placed graphics)

                      All text flows in the Creator document are recreatedas text frames in the InDesign document.

                      Everything is adjust so that layering is correct.

                      The new Indesign document is then saved in the same location as the Creator document using the same name.



                      Creator handles fonts differently than Indesign. Instead of using italics or bold from the font family it would apply stroke or skew the text. I have that nearly sorted out so that it works nearly perfectly, but the leading was not coming over properly 100% of the time.


                      What I thought should work wasn't and that was bugging me as one of those "I'll come back to it later" things I hadn't come back to yet.