Skip to main content
BurtonDev
Inspiring
July 26, 2018
Answered

Can color of text in text field be set to CMYK?

  • July 26, 2018
  • 3 replies
  • 5405 views

I am trying to programmatically set the color of text fields in my document using a CMYK color space so that the text will be ready to print.

Some fields have the fill color set while others have the text color set. It is painfully clear that while they are both set to the same color, they display very different colors. For example, setting these fields to a teal color will result in the fill color being true and the text color looking a very different aqua-green.

After much investigation, I suspect that the text color can only be set to RGB values. When I try to manually set the text color, there is no option to select CMYK colors.

Is this truly the case or am I overlooking something? And if it is, is there a way that I can ensure that when the user prints the document, all colors will print in CMYK? Even so, they should be able to view the text in CMYK so that they know what to expect on the printed document...

Any help is greatly appreciated!

This topic has been closed for replies.
Correct answer BurtonDev

For anyone reading that might be facing the same (or a similar) problem: I think this comment will piece together this puzzle, providing the best explanation of what's going on, plus the workaround that I came up with,

Problem: Inconsistent Display of CMYK Values

It is not possible to manually apply CMYK values as fill or text colors, but it is possible to set these to a CMYK value programmatically via JavaScript.

However, Acrobat produces visibly different colors when doing so. For example,

A button filled with ["CMYK",0.62,0,0.23,0]:

Text filled using the same value, ["CMYK",0.62,0,0.23,0]:

Conundrum: Which Is Displaying The Correct Value?

Comparing the colors to a CMYK color swatch produced in InDesign for the same value, it would appear that the fill is displaying the color correctly whereas the text is not.

But is this really the case?

CMYK and RGB are converted using math formulas, such as those found here.

This means that mathematically, ["CMYK",0.62,0,0.23,0] and ["RGB",97,255,196] are equal. Popping the CMYK value into a color picker will produce the greenish color shown in the text example above.

When I printed the above examples, I was surprised to see that although the Acrobat fill color was the best on-screen match for the InDesign swatch, the best match on paper was the garish green text color. It did not look the same printed - it had more blue tones, was softer, and basically looked like teal should look.

Even when I printed from InDesign, making sure that the right color profile was selected for my printer and that the printer's driver did not override ID, the color was not a close match.

Explanation (so far...)

["CMYK",0.62,0,0.23,0] and ["RGB",97,255,196] are only equal if using the same conversion factor. The ones found on EasyRGB seem to be commonly used for the web and HTML. How a color is converted depends on the color management system, and clearly ID's color management differs.

My current theory for why fill and text color look different in Acrobat is that Acrobat's color management system treats fill and text colors differently. It seems to treat CMYK fills similarly to how InDesign treats CMYK values, but Acrobat treats CMYK text differently - in this latter case, it appears to use a different algorithm.

If this is not the reason why the colors look different, then I have no idea what is. It is not because the .textColor property is being converted to RGB. I tested this by setting the .textColor to ["CMYK",0.62,0,0.23,0] and then using the console log to retrieve the color of the text. It retrieved, "["CMYK",0.62,0,0.23,0]". If it would have been converted "behind the scenes" by Acrobat, then the console should have retrieved an array containing RGB values.

In reality, all colors that we look at on a computer monitor are RGB colors. The only time we actually see a CMYK color is when looking at a CMYK print.

Workaround

What I'm doing so far as a workaround is to set different colors for viewing and for printing.

Basically, I am using InDesign's color management to convert CMYK colors to RGB and then setting both the .fillColor and .textColor properties of the fields that I want to color in Acrobat with this InDesign-generated RGB value. This seems to produce the most consistent colors across the two properties, i.e. fills and text end up looking the same color.

By printing the document with the RGB values, I can pinpoint which colors are too drastically different, such as the teal, and focus on a workaround for them, ignoring the rest to try and reduce workaround time.

When it's time to print, a "Document Actions" script assigned to "Document Will Print" can change all problem colors to CMYK before printing (you can, of course, opt to convert all colors to CMYK - perhaps this will make the document more consistent or at least more predictable across different printers).

I tested this with a sample and it worked.

The catch here is that it changes the colors for the print preview. If your users are expecting the print preview to match the form that they see on screen, they will need to be notified that the colors will look different but should print correctly, so that they are not alarmed when they see how the colors have changed on the print preview screen.

Warning*** this workaround is tedious*** but it works. If you try it, make sure to check your results in print and tweak accordingly.

Update: Just wanted to add that instead of changing the color of the fields programmatically before printing, you can also experiment with using scripts to convert color, such as colorConvertPage(), or set color profile/Preflight, etc. on a Document Will Print script.

3 replies

BurtonDev
BurtonDevAuthorCorrect answer
Inspiring
July 27, 2018

For anyone reading that might be facing the same (or a similar) problem: I think this comment will piece together this puzzle, providing the best explanation of what's going on, plus the workaround that I came up with,

Problem: Inconsistent Display of CMYK Values

It is not possible to manually apply CMYK values as fill or text colors, but it is possible to set these to a CMYK value programmatically via JavaScript.

However, Acrobat produces visibly different colors when doing so. For example,

A button filled with ["CMYK",0.62,0,0.23,0]:

Text filled using the same value, ["CMYK",0.62,0,0.23,0]:

Conundrum: Which Is Displaying The Correct Value?

Comparing the colors to a CMYK color swatch produced in InDesign for the same value, it would appear that the fill is displaying the color correctly whereas the text is not.

But is this really the case?

CMYK and RGB are converted using math formulas, such as those found here.

This means that mathematically, ["CMYK",0.62,0,0.23,0] and ["RGB",97,255,196] are equal. Popping the CMYK value into a color picker will produce the greenish color shown in the text example above.

When I printed the above examples, I was surprised to see that although the Acrobat fill color was the best on-screen match for the InDesign swatch, the best match on paper was the garish green text color. It did not look the same printed - it had more blue tones, was softer, and basically looked like teal should look.

Even when I printed from InDesign, making sure that the right color profile was selected for my printer and that the printer's driver did not override ID, the color was not a close match.

Explanation (so far...)

["CMYK",0.62,0,0.23,0] and ["RGB",97,255,196] are only equal if using the same conversion factor. The ones found on EasyRGB seem to be commonly used for the web and HTML. How a color is converted depends on the color management system, and clearly ID's color management differs.

My current theory for why fill and text color look different in Acrobat is that Acrobat's color management system treats fill and text colors differently. It seems to treat CMYK fills similarly to how InDesign treats CMYK values, but Acrobat treats CMYK text differently - in this latter case, it appears to use a different algorithm.

If this is not the reason why the colors look different, then I have no idea what is. It is not because the .textColor property is being converted to RGB. I tested this by setting the .textColor to ["CMYK",0.62,0,0.23,0] and then using the console log to retrieve the color of the text. It retrieved, "["CMYK",0.62,0,0.23,0]". If it would have been converted "behind the scenes" by Acrobat, then the console should have retrieved an array containing RGB values.

In reality, all colors that we look at on a computer monitor are RGB colors. The only time we actually see a CMYK color is when looking at a CMYK print.

Workaround

What I'm doing so far as a workaround is to set different colors for viewing and for printing.

Basically, I am using InDesign's color management to convert CMYK colors to RGB and then setting both the .fillColor and .textColor properties of the fields that I want to color in Acrobat with this InDesign-generated RGB value. This seems to produce the most consistent colors across the two properties, i.e. fills and text end up looking the same color.

By printing the document with the RGB values, I can pinpoint which colors are too drastically different, such as the teal, and focus on a workaround for them, ignoring the rest to try and reduce workaround time.

When it's time to print, a "Document Actions" script assigned to "Document Will Print" can change all problem colors to CMYK before printing (you can, of course, opt to convert all colors to CMYK - perhaps this will make the document more consistent or at least more predictable across different printers).

I tested this with a sample and it worked.

The catch here is that it changes the colors for the print preview. If your users are expecting the print preview to match the form that they see on screen, they will need to be notified that the colors will look different but should print correctly, so that they are not alarmed when they see how the colors have changed on the print preview screen.

Warning*** this workaround is tedious*** but it works. If you try it, make sure to check your results in print and tweak accordingly.

Update: Just wanted to add that instead of changing the color of the fields programmatically before printing, you can also experiment with using scripts to convert color, such as colorConvertPage(), or set color profile/Preflight, etc. on a Document Will Print script.

Legend
July 27, 2018

Sadly, PDF forms were never conceived of as press ready. Just rough and ready files for typing in. People regularly try to make it go further than that, and are regularly disappointed.

try67
Community Expert
Community Expert
July 26, 2018

It's possible to do it, but only with a script. For example, the following code will set the fill color of a field called "Text1" to CMYK red:

this.getField("Text1").fillColor = ["CMYK", 0, 1, 1, 0];

Notice the values range from 0 to 1.

try67
Community Expert
Community Expert
July 26, 2018

To change the text color replace fillColor with textColor in the code above...

BurtonDev
BurtonDevAuthor
Inspiring
July 26, 2018

try67​, thanks for your prompt reply.

I should have been more clear. When I stated that I was trying to change the text color programmatically, I was referring to JavaScript (ACRO script).Despite using the same CMYK code, .fillColor and .textColor produce different colors, sometimes dramatically different, depending on the color.

Are there any other answers?