2 Replies Latest reply on Sep 2, 2013 7:11 PM by MichaelN

    Can JavaScript adjust line spacing in annotations?

    Chris Aiken

      I'm trying to write a script that will change the color of all comments in a document to blue.  Right now, I can change all the colors, but the resulting file has text boxes with different line spacing than the original.  This is especially noticable for large blocks of text like the ones put in by Typewriter users with a lot to say.  Is there any way to control line spacing using JavaScript?  I'm using Adobe Acrobat X Pro on a Windows 7 machine.  The code is below.  Thanks for your help!

       

      //Select all the annotations/comments in the file

      var annots = this.getAnnots()

       

      //Prepare an array to turn shapes and lines blue

      var myProps = {strokeColor: color.blue};

       

      //Do the following for each annotation

      for (var j =0; j<annots.length;j++){

       

           //Turn shapes and lines blue

           annots[j].setProps(myProps);

       

           //If there is text in the annotation

           if (annots[j].contents !== ""){

       

           //Prepare an array to edit the text

           var spans = new Array();

       

           //Do the following for each line of text

           for (var i =0; i<annots[j].richContents.length;i++){

         

                //Prepare an object to edit the text with

                spans[i] = new Object();

       

                //Ensure the object is identical to the original in everything except color

                spans[i].text = annots[j].richContents[i].text;

                spans[i].alignment = annots[j].richContents[i].alignment;

                spans[i].fontFamily = annots[j].richContents[i].fontFamily;

                spans[i].textSize = annots[j].richContents[i].textSize;

       

                //Make the text blue

                spans[i].textColor = color.blue;}

       

           //Apply the object to the annotation, turning it blue

           annots[j].richContents = spans;

      }}