Skip to main content
Inspiring
August 26, 2020
Answered

how to change the color of the textframe content ?

  • August 26, 2020
  • 5 replies
  • 2595 views

Hey all,

 

small question, I've searched for a way to change only the color of the text in the frame, and all the ways was to fill the frame or the border.

 

This's my code, how can i change only the color of the content! 

	var rect = doc.pages[0].textFrames.add({
			geometricBounds: [41, 53, 46, 64]
		});
		rect.contents = "HEYYY"

 

i'm using JS.

thanks all.

 

This topic has been closed for replies.
Correct answer Manan Joshi

Use the swatch named [Paper] it preexists. If it does not work with [] the use the name without it

-Manan

5 replies

Manan JoshiCommunity ExpertCorrect answer
Community Expert
August 26, 2020

Use the swatch named [Paper] it preexists. If it does not work with [] the use the name without it

-Manan

-Manan
Inspiring
August 26, 2020

Thanks so much it works!

 

Community Expert
August 26, 2020

The swatch that you are trying to apply, i.e., the one with the name "C=0 M=0 Y=0 K=0" does it exist in the document? Can you see it in the swatches panel? What I mean is if you don't have the color created, then you can't use it. For more details on how to create a swatch see the following

https://helpx.adobe.com/in/indesign/using/swatches.html#create_color_swatches

-Manan

-Manan
Inspiring
August 26, 2020

I undetstand that sure!! But i dont understand why the color white not exist! 

Participant
September 17, 2022

White is not a color - it is the complete absence of color.

Community Expert
August 26, 2020

Did you create the colour with that name before trying to use it? I don't see any issue with the code you have and it works fine for me

-Manan

-Manan
Inspiring
August 26, 2020

What do you mean about creating color?

Community Expert
August 26, 2020

Another option would be designing a paragraph style or character style with the proper colour that you need to use and apply that to the content of your textframe. The code snippet I gave will apply the colour but would cause style overrides, if you want to keep the overrides away you can try using styles

-Manan

-Manan
Community Expert
August 26, 2020

Try the following, change the name of the swatch as needed

rect.texts[0].fillColor = app.documents[0].swatches.itemByName("C=75 M=5 Y=100 K=0")

-Manan

 

-Manan
Inspiring
August 26, 2020

Hey Manan, I've tried it, it works. But i want the color to be white.

so, i tried to do this but it informs me that it's invalid value for the set property 'fillcolor'.

rectBefore.texts[0].fillColor = app.documents[0].swatches.itemByName("C=0 M=0 Y=0 K=0")