3 Replies Latest reply on Apr 16, 2009 3:03 PM by Olav Martin Kvern

    how to change label color in LabelGraphics script?

      I am using ID CS4 and running the LabelGraphics script to label several images in a large document. When I run thre script, the box with the file name is transparent with black type. I would like the box to be white with black type. Is there any way to edit the script that will enable this? It would be great if there was an "object style" in addition to the "paragraph style" in the run script pop-up window. Anyone?

        • 1. Re: how to change label color in LabelGraphics script?
          [Jongware] Most Valuable Participant

          I was going to try but decided to look around a bit. Check out Modified Script Adds Captions From Clipboard to Images. The modified script by Steve Wareham allows you to set a background color; and you can use the Style dropdown to select a paragraph style that has '[Paper]' as the text color.

           

          [Edit] Um. You want black text. Well, the gist of it is that you set it in the paragraph style for your caption, so still no sweat.

          • 2. Re: how to change label color in LabelGraphics script?
            Level 1

            Thanks a million!! This works great. Thanks so much for solving my problem.

            • 3. Re: how to change label color in LabelGraphics script?
              Olav Martin Kvern Level 3

              Hi hylet,

               

              Here's how to change the LabelGraphics.jsx script itself to add an object style option:

               

              1. Look for the line:

               

              var myStyleNames = myGetParagraphStyleNames();

               

              And add this line before or after it:

               

              var myObjectStyleNames = app.documents.item(0).objectStyles.everyItem().name;

               

              2. Look for the lines:

               

              //Style to apply
              with(dialogRows.add()){
                   with(dialogColumns.add()){
                        staticTexts.add({staticLabel:"Label Style", minWidth:myLabelWidth});
                    }
                   with(dialogColumns.add()){
                        var myLabelStyleDropdown = dropdowns.add({stringList:myStyleNames, selectedIndex:0});
                   }
              }

               

              And add the following lines after them:

               

              //Object style to apply to the text frame
              with(dialogRows.add()){
                   with(dialogColumns.add()){
                        staticTexts.add({staticLabel:"Label Object Style", minWidth:myLabelWidth});
                   }
                   with(dialogColumns.add()){
                        var myObjectStyleDropdown = dropdowns.add({stringList:myObjectStyleNames, selectedIndex:0});
                   }

              }

               

              3. Look for the line:

               

              var myLabelStyle = myStyleNames[myLabelStyleDropdown.selectedIndex];

              And add this line before or after it:

               

              var myObjectStyleName = myObjectStyleNames[myObjectStyleDropdown.selectedIndex];

               

              4. Look for the line:

               

              myAddLabels(myLabelType, myLabelHeight, myLabelOffset, myLabelStyle);

               

              And change it to:

               

              myAddLabels(myLabelType, myLabelHeight, myLabelOffset, myLabelStyle, myObjectStyleName);

               

              5. Look for the line:

               

              function myAddLabels(myLabelType, myLabelHeight, myLabelOffset, myLabelStyleName){

               

              And change it to:

               

              function myAddLabels(myLabelType, myLabelHeight, myLabelOffset, myLabelStyleName, myObjectStyleName){

              6. Look for the line:

               

              myAddLabel(myDocument, myGraphics[myCounter], myLabelType, myLabelHeight, myLabelOffset, myLabelStyle);

               

              And change it to:

               

              myAddLabel(myDocument, myGraphics[myCounter], myLabelType, myLabelHeight, myLabelOffset, myLabelStyle, myObjectStyleName);

               

              7. Look for the line:

               

              function myAddLabel(myDocument, myGraphic, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle){

               

              And change it to:

               

              function myAddLabel(myDocument, myGraphic, myLabelType, myLabelHeight, myLabelOffset, myLabelStyle, myObjectStyleName){

               

              8. Look for the line:

               

              var myTextFrame = myFrame.parent.textFrames.add(myLabelLayer, undefined, undefined,{geometricBounds:[myY1, myX1, myY2, myX2], contents:myLabel});

               

              And add the following line after it:

               

              myTextFrame.applyObjectStyle(app.documents.item(0).objectStyles.item(myObjectStyleName), true);

               

              9. (Optional) Look for the line:

               

              myTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

               

              And delete it or put "//" in front of it--this will let the object style take care of setting the first baseline offset method.

               

              After you make these changes, the script adds the object style dropdown to the dialog:

               

              LabelGraphicsModified.jpg

               

              Thanks,

               

              Ole