Changing textcolor driven by database
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Changing textcolor driven by database
Tagged: datamerge text color
- This topic has 10 replies, 4 voices, and was last updated 7 years, 2 months ago by Loic Aigon.
-
AuthorPosts
-
-
February 5, 2017 at 6:32 am #91966Steven HimpeMember
Maybe a simple question, but I can’t find it.
Imagine I would like to make business cards with first and last name. Depending on Male of Female I would like to change the color of the variable firstname from blue to red. The gender is also in the database.
Can someone explain me how to do this ? -
February 5, 2017 at 6:56 am #91967David BlatnerKeymaster
Are you creating the cards with Data Merge? One idea would be to put the variable or the color on the same paragraph as the name. So it would come in as something like “Male:Steven Himpe”. And set up the template so that it comes in with a paragraph style that has a GREP style in it… and the GREP style could make the word “Male:” disappear (apply a character style that makes that text 0.01 pt large and a color of None) and then make the first word after “Male:” the color you want (again, with a character style).
-
February 5, 2017 at 7:08 am #91968Steven HimpeMember
Sounds complex, but I’ll try to read some more about GREP styles. This seems to me a simple question but not so simpel te do. :)
Thanks anyway.
-
February 5, 2017 at 10:09 am #91969Mike WenzloffMember
I imagine this could be scripted…not be me, but by someone who actually knows how to script in ID…
If I were doing this as a merge, I would just use Em Software’s InData as it can do this without needing to hide anything. One would write the merge script to allow for the two conditions and use the appropriate character style and at the merge it just happens. InData also has far greater utility for merging than just for something like this and if you do merging much, take a look at it.
Mike
-
February 6, 2017 at 3:54 am #91970Loic AigonMember
No need for scripting specifically. This can be achieved with a grep style.
All you have to do is use a character as a “fill” character. Its fill color will be related to the gender.
HTH
[EDIT] Well I thought the [img] tag would make the images to be loaded but it doesn’t seem to be the case.
Loic
-
February 6, 2017 at 8:14 am #91975David BlatnerKeymaster
Loic: I think it was because the image service URL you used looked like a png, but it was actually an html/php file that pointed to a png. Tricky! I fixed the urls for you. :-)
For readers: Loic’s idea is that you just insert a HUGE black rectangle character (a glyph that looks like a black rectangle) in a text frame and then change the color of that whole paragraph (including the based on the first character. The rectangle is so big that it fills the whole page, I guess. Interesting!
-
February 6, 2017 at 8:19 am #91976Loic AigonMember
Hi David,
Thanks for the fix and precisions. I should have given more details indeed. I don’t claim it’s how I would do it. As an EasyCatalog pro, I would advice differently but I thought it was interesting to share the trick anyway.
Loic
-
February 6, 2017 at 10:25 am #91977Steven HimpeMember
Thanks a lot Loic & David !!!
I know what to do next weekend :) -
February 6, 2017 at 3:09 pm #91996Loic AigonMember
In the meanwhile no one saw the musical reference :(
-
February 6, 2017 at 3:27 pm #92000David BlatnerKeymaster
Um… James Brown?
-
February 6, 2017 at 3:49 pm #92003Loic AigonMember
Curtis Mayfield ;)
https://www.youtube.com/watch?v=xchdtRWwaDo
-
-
AuthorPosts
- You must be logged in to reply to this topic.