Highlighted

Text color

Explorer ,
Sep 03, 2020

Copy link to clipboard

Copied

Can javascript be used to change color of part of the text.

Example: today was sunny day.

can word "sunny" be yellow and rest of the text default color (black).

I already tried CTRL+E but text in textbox is dynamic and it reset to default when changed.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Yes, this can be done by setting the field as having Rich Text Formatting and then setting its richValue property as an array of Span objects, each one representing a contiguous string of text with identical properties.

In this case you would have 3 spans:

- "today was " would be a Span with black text.

- "sunny" would be a Span with yellow text.

- " day." would be a Span with black text.

TOPICS
Acrobat SDK and JavaScript, How to

Views

32

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

Explorer ,
Sep 03, 2020

Copy link to clipboard

Copied

Can javascript be used to change color of part of the text.

Example: today was sunny day.

can word "sunny" be yellow and rest of the text default color (black).

I already tried CTRL+E but text in textbox is dynamic and it reset to default when changed.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Yes, this can be done by setting the field as having Rich Text Formatting and then setting its richValue property as an array of Span objects, each one representing a contiguous string of text with identical properties.

In this case you would have 3 spans:

- "today was " would be a Span with black text.

- "sunny" would be a Span with yellow text.

- " day." would be a Span with black text.

TOPICS
Acrobat SDK and JavaScript, How to

Views

33

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
Sep 03, 2020 0
Most Valuable Participant ,
Sep 03, 2020

Copy link to clipboard

Copied

Yes, this can be done by setting the field as having Rich Text Formatting and then setting its richValue property as an array of Span objects, each one representing a contiguous string of text with identical properties.

In this case you would have 3 spans:

- "today was " would be a Span with black text.

- "sunny" would be a Span with yellow text.

- " day." would be a Span with black text.

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...
Sep 03, 2020 0
Marietaa LATEST
Explorer ,
Sep 03, 2020

Copy link to clipboard

Copied

Thanks again Try67 you'r the best.

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...
Sep 03, 2020 0