Copy link to clipboard
Copied
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.
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
Use the swatch named [Paper] it preexists. If it does not work with [] the use the name without it
-Manan
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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")
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
What do you mean about creating color?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
I undetstand that sure!! But i dont understand why the color white not exist!
Copy link to clipboard
Copied
White is not a color - it is the complete absence of color.
Copy link to clipboard
Copied
It depends on how you approach it.
For print, white is the absence of INK (subtractive color). Technically, the paper tint would show through, which is why InDesign calls it "Paper".
From a physics viewpoint, white is the combination of all colors (additive color).
Copy link to clipboard
Copied
Use the swatch named [Paper] it preexists. If it does not work with [] the use the name without it
-Manan
Copy link to clipboard
Copied
Thanks so much it works!