Text Color in Span Object

Community Beginner ,
Nov 15, 2018

Copy link to clipboard

Copied

Hi, I’ve created a business card template in Acrobat Pro and our logo colors are used in the executive business cards.

The employee name is in a burgundy color: RGB = 179, 15, 65

The remaining text is in a dark green color: RGB = 0, 56 34

My coding for the employee name is below. The third spans line is my attempt at changing the text color. Something is wrong because the text looks like a florescent teal. I get the sane teal color with the green RGB colors.

var spans = event.richValue;

spans[0] = new Object();

spans[0].text = this.getField("EmpName").valueAsString + "\r";

spans[0].textColor = ["RGB", 179, 15, 65]; //Burgundy

spans[0].fontWeight = 700; //this makes the font bold

spans[0].textSize = 9;

event.richValue = spans;

Thanks for your time and assistance.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Divide the values in the Color object by 255 to get them in the right range (0 to 1).

TOPICS
Acrobat SDK and JavaScript, Windows

Views

145

Likes

Translate

Translate

Report

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

Text Color in Span Object

Community Beginner ,
Nov 15, 2018

Copy link to clipboard

Copied

Hi, I’ve created a business card template in Acrobat Pro and our logo colors are used in the executive business cards.

The employee name is in a burgundy color: RGB = 179, 15, 65

The remaining text is in a dark green color: RGB = 0, 56 34

My coding for the employee name is below. The third spans line is my attempt at changing the text color. Something is wrong because the text looks like a florescent teal. I get the sane teal color with the green RGB colors.

var spans = event.richValue;

spans[0] = new Object();

spans[0].text = this.getField("EmpName").valueAsString + "\r";

spans[0].textColor = ["RGB", 179, 15, 65]; //Burgundy

spans[0].fontWeight = 700; //this makes the font bold

spans[0].textSize = 9;

event.richValue = spans;

Thanks for your time and assistance.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Divide the values in the Color object by 255 to get them in the right range (0 to 1).

TOPICS
Acrobat SDK and JavaScript, Windows

Views

146

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 15, 2018 0
Most Valuable Participant ,
Nov 15, 2018

Copy link to clipboard

Copied

Colour values are in the range 0.0 to 1.0 in other parts of JavaScript. I’d double check this.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 15, 2018 0
Most Valuable Participant ,
Nov 15, 2018

Copy link to clipboard

Copied

Divide the values in the Color object by 255 to get them in the right range (0 to 1).

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 15, 2018 1
Angus24 LATEST
Community Beginner ,
Nov 15, 2018

Copy link to clipboard

Copied

Om my gosh! That's it. Thank you so much try67!!!

YOU ROCK

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 15, 2018 0