1 Reply Latest reply on Jul 14, 2009 6:55 AM by Kasyan Servetsky

    Setting Font Color [CS3][JS]

    MDSYNTST

      Hello,

       

      I am looking for a way to set the color of a piece of text that I'm inserting on the page.  I have found information about how to use a swatch color to do it, but I can't find anything about setting the color based on CMYK values without having to create a swatch first.  Likely I just don't know what properties/methods I'm searching for.

       

      I'm using insertion points to control the location of my text in the frame.  My code looks like this:

       

      r = app.activeWindow.activeSpread.groups.item('Group-1').textFrames.item('Text1');
      ip = r.insertionPoints.item(0);
      ip.appliedFont = 'ARIAL';
      ip.fillTint = 70;
      ip.tracking = +100;

       

      //ip.colorSettings.colorSpace [CMYK] :: Process [C=100, M=0, Y=0, K=0]  -- Not sure if this should be one line or two, and no clue how to write it - obviously.
      //ip.fillColor = 'Blue';

       

      ip.contents = 'This is the text that should appear process cyan based on the CMYK settings.';

       

       

       

      So as you can see, right now I can use a swatch, but I need to loop this script over many files and I don't really want the swatch created in all those files.

       

      Any help is appreciated.

       

      Thanks,
      Dave

        • 1. Re: Setting Font Color [CS3][JS]
          Kasyan Servetsky Level 5

          You can't directly set the fill or stroke to an arbitrary color specification — it has to be a color, swatch,  a mixed ink, a tint, or a gradient. When you apply a color using the Colors panel, in the user interface, InDesign creates a color object, even though the color object does not appear in the Swatches panel. These colors appear as unnamed colors to scripting, but they're still color objects.

           

          To apply a color via InDesign scripting, you must use a color or swatch object.