Skip to main content
FaLeb
Participant
March 23, 2018
Answered

Javascript colour

  • March 23, 2018
  • 1 reply
  • 2132 views

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,

This topic has been closed for replies.
Correct answer try67

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.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 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.

FaLeb
FaLebAuthor
Participant
March 23, 2018

This is fabulous, thanks so much!

FaLeb
FaLebAuthor
Participant
March 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.