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

Javascript colour

New Here ,
Mar 23, 2018 Mar 23, 2018

Hi,

In a PDF document, I want to change the colour of a button by using this code:

event.target.fillColor = color.black;

How can I personalize the colour? The RGB colour is 190, 21, 34.

Thanks,

TOPICS
PDF forms
1.9K
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 ,
Mar 23, 2018 Mar 23, 2018

The color object in Acrobat JS is an array with a color-space name and the values between 0 and 1.

So your example would be:

event.target.fillColor = ["RGB", 190/255, 21/255, 34/255];

By the way, in the future please post follow-up questions under the original thread.

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 ,
Mar 23, 2018 Mar 23, 2018

The color object in Acrobat JS is an array with a color-space name and the values between 0 and 1.

So your example would be:

event.target.fillColor = ["RGB", 190/255, 21/255, 34/255];

By the way, in the future please post follow-up questions under the original thread.

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
New Here ,
Mar 23, 2018 Mar 23, 2018

This is fabulous, thanks so much!

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
New Here ,
Mar 23, 2018 Mar 23, 2018

Do you think it's possible to make it change to white when I click again on the button?

What I mean is that I click once, it turns red, if I click again it turns to white and vice-versa.

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 ,
Mar 23, 2018 Mar 23, 2018

Sure, that's possible. You can use this code to it:

if (color.equal(event.target.fillColor, color.white)) event.target.fillColor = ["RGB", 190/255, 21/255, 34/255];

else event.target.fillColor = color.white;

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
New Here ,
Mar 23, 2018 Mar 23, 2018
LATEST

It works perfectly ! I really appreciate your help, 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