Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Validation Scripting and Colors

Explorer ,
Feb 20, 2017 Feb 20, 2017

Another dumb question...I'm using the following scripting to produce the colored values in the image below:

if (event.value>Number(this.getField("AverageCovg").value))  

event.target.fillColor = color.green; 

else event.target.fillColor = color.red; 

It works like a charm, BUT ... how do you modify the colors so it's a different shade (darker)? I'm looking to have it produce a darker green and red, instead of the bright green and red that seem to be standard.

Appreciate any help!

2-20-2017 8-14-54 PM.jpg

TOPICS
PDF forms
685
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Feb 21, 2017 Feb 21, 2017

If you want to specify a custom color you need to know its RGB values, and then convert them to the format that Acrobat JS uses, which is a number between 0 and 1, instead of the normal 0-255.

So let's take "Forest Green", which is defined as "34-139-34". To use it in our script we need to convert the values, by dividing them by 255 and then put them in a special array, like so:

var myForestGreen = ["RGB", 34/255, 139/255, 34/255];

Then we can use it in the code like this:

event.target.fillColor = myForestGreen;

The same can be done using CMYK values, by the way, or gray-scale.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 21, 2017 Feb 21, 2017

If you want to specify a custom color you need to know its RGB values, and then convert them to the format that Acrobat JS uses, which is a number between 0 and 1, instead of the normal 0-255.

So let's take "Forest Green", which is defined as "34-139-34". To use it in our script we need to convert the values, by dividing them by 255 and then put them in a special array, like so:

var myForestGreen = ["RGB", 34/255, 139/255, 34/255];

Then we can use it in the code like this:

event.target.fillColor = myForestGreen;

The same can be done using CMYK values, by the way, or gray-scale.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 21, 2017 Feb 21, 2017

PS. It's not a dumb question at all...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 21, 2017 Feb 21, 2017
LATEST

Again, thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines