2 Replies Latest reply on Nov 13, 2017 1:46 AM by jacekj59956765

    Horizontal display problem

    jacekj59956765

      Hi, i'm just starting with javascript and i have a problem.

      How do I make the ink List display horizontally with breaks like this:

      Ink_problem_2_Obszar roboczy 1_Obszar roboczy 1.jpg

       

      Now I have:

      Ink_problem_1_Obszar roboczy 1.jpg

       

      And I can not figure out how to do it ...

       

       

      var docRef=app.activeDocument;

       

       

      //Create 100% CMYK colors to be assigned to the process inks.

      var processCyan = new CMYKColor();

      processCyan.black = 0;

      processCyan.cyan = 100;

      processCyan.magenta = 0;

      processCyan.yellow = 0;

      var processMagenta = new CMYKColor();

      processMagenta.black = 0;

      processMagenta.cyan = 0;

      processMagenta.magenta = 100;

      processMagenta.yellow = 0;

      var processYellow = new CMYKColor();

      processYellow.black = 0;

      processYellow.cyan = 0;

      processYellow.magenta = 0;

      processYellow.yellow = 100;

      var processBlack = new CMYKColor();

      processBlack.black = 100;

      processBlack.cyan = 0;

      processBlack.magenta = 0;

      processBlack.yellow = 0;

       

       

      //Prompt the user for the desired text size.

      var SepTextSize=Window.prompt("Enter the desired text size in points:", 9);

      //Variable for specifying font by name.//Ensure the size will be interpreted as a number, not as text.

      var sepTextSize=parseFloat(SepTextSize);

      //Vertical and horizontal location for the labels.

      var sepTextTop=sepTextSize;

      var sepTextX= 6;

      var sepTextY = sepTextSize/2;

      var sepTextFont = textFonts.getByName("MyriadPro-Cond");

       

       

       

       

       

       

       

       

       

       

      //Loop through the members of the document's inkList.

      for(i=docRef.inkList.length-1;i>=0;i--){

      var inkRef=docRef.inkList[i]; //Variable for the current ink.

           var inkRefName=inkRef.name; //Variable for the current ink's name.

       

       

            //Create a pointText object for the current ink's label.

           var sepTextLabel = docRef.textFrames.pointText([sepTextX,sepTextY]);

      sepTextLabel.contents = inkRefName; //Set its content to the name of the ink.

          sepTextLabel.textRange.characterAttributes.size=sepTextSize; //Set its text size as was specified by user.

          sepTextLabel.textRange.characterAttributes.leading=sepTextSize;//Set its leading 100% of its text size.

          sepTextLabel.textRange.characterAttributes.textFont = sepTextFont

         

       

       

       

       

         

         

          switch (inkRef.inkInfo.kind) {

              case InkType.CYANINK://If the current ink is Cyan.

              sepTextLabel.textRange.characterAttributes.fillColor=processCyan;//Fill the characters with processCyan.

          sepTextLabel.contents = "Cyan " + '\r' + docRef.inkList[i].inkInfo.frequency + "lpi"  + "/" + docRef.inkList[i].inkInfo.angle; // nazwa inku

             

             

              break;

              case InkType.MAGENTAINK://If the current ink is Magenta.

              sepTextLabel.textRange.characterAttributes.fillColor=processMagenta;//Fill the characters with processMagenta.

              sepTextLabel.contents = "Magenta" ;

              break;

              case InkType.YELLOWINK://If the current ink is Yellow.

              sepTextLabel.textRange.characterAttributes.fillColor=processYellow;//Fill the characters with processYellow.

              sepTextLabel.contents = "Yellow" ;

              break;

              case InkType.BLACKINK://If the current ink is Black.

              sepTextLabel.textRange.characterAttributes.fillColor=processBlack;//Fill the characters with processBlack.

              sepTextLabel.contents = "Black" ;

              break;

              case InkType.CUSTOMINK://If the current ink is a spot color.

              sepTextLabel.textRange.characterAttributes.fillColor=docRef.swatches.getByName(inkRefName ).color;//Fill it with the Swatch that is named the same as the ink.

              sepTextLabel.contents = inkRefName + '\r' + docRef.inkList[i].inkInfo.frequency + "lpi"  + "/" + docRef.inkList[i].inkInfo.angle;

              break;

              default://Otherwise.

              sepTextLabel.textRange.characterAttributes.fillColor=docRef.swatches.getByName("[Registra tion]").color;//Fill the characters with Registration.

              }//end switch}//end for

          }

        • 1. Re: Horizontal display problem
          CarlosCanto Adobe Community Professional & MVP

          you're adding all text frames at the same location, [sepTextX, sepTextY]

           

          you need to increase X position (sepTextX) after each pass. So, ink 2 will be your current x position + the width of the text frame + any spacing you want between frames

           

          // declare a variable for spacing before you start your loop
          var spacing = 15;
          

           

          then way at the end of the the loop, before the closing curly brace, increase you X position, so ink 2 gets added correctly

           

              sepTextX = sepTextX + sepTextLabel.width + spacing;
          } // closing for loop curly brace
          
          • 2. Re: Horizontal display problem
            jacekj59956765 Level 1

            You are genius!

            Thanks, you helped me a lot, now I understand that