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

Underlining a Single Word within a Text Field in Acrobat DC

Community Beginner ,
Sep 26, 2017 Sep 26, 2017

Copy link to clipboard

Copied

I would like to know if it is possible to underline a word within a text field. In my example below I want to underline the word MINOR: only.

This is my coding:

event.value="MINOR: " + this.getField(“BName”).valueAsString;

I want the above to look like this:

MINOR: Jane Doe

Is this possible?

Thank you

TOPICS
Acrobat SDK and JavaScript , Windows

Views

688

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
community guidelines
Community Expert ,
Sep 26, 2017 Sep 26, 2017

Copy link to clipboard

Copied

This is possible. Use rich text format in the text field and the JavaScript span object.

Votes

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
community guidelines
Community Beginner ,
Sep 27, 2017 Sep 27, 2017

Copy link to clipboard

Copied

Thanks for your response Bernd, but I'm still at a loss on how to do this.

Can you help me out with the coding for this?

Votes

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
community guidelines
Community Expert ,
Sep 27, 2017 Sep 27, 2017

Copy link to clipboard

Copied

See the documentation at the link below

Acrobat DC SDK Documentation

Example 1 will show you how to underline some text.

Example 2 shows you the rest of what you need to do to construct a set of span objects that have different formatting and then set that as the rich text value. In your use case, you'd need two spans.

Votes

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
community guidelines
Community Beginner ,
Sep 27, 2017 Sep 27, 2017

Copy link to clipboard

Copied

Hi Joel, thank you for the link. In looking at the link you sent, I don’t want to underline the text field BName in my example, I want to underline the text I’m putting in front of the text field. And after reviewing the information you sent I still don’t know how to do this. 

So my situation is this: my calculation script in text field Text 10 is:

event.value="MINOR: " + this.getField("BName").valueAsString;

I want MINOR: to be underlined not the text field BName

MINOR: Jane Doe

The info that you provided reads, to me, that the underline would be for the entire field of BName, which is not what I want.

Sorry, I’m  not understanding the information you provided.

Votes

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
community guidelines
Community Expert ,
Sep 27, 2017 Sep 27, 2017

Copy link to clipboard

Copied

You'd create a span for "MINOR:" and set the properties to underline it. Then another span for the field value and set the properties for that.

Then you'll need to modify your calculation for Text 10 so that it sets the rich value of the field rather than the value of the calculation event. Use...

event.target.richValue = spans

...like in the example

Votes

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
community guidelines
Community Beginner ,
Sep 28, 2017 Sep 28, 2017

Copy link to clipboard

Copied

Okay, below is what I got out of the information you provided.

var f = this.getField("Text10");

var spans = f.richValue;

spans[0].underline = true;

f.richValue = spans;

var spans = new Array();

var spans = new Object();

spans[0].text = "MINORS: ";

spans[0].underline = true;

event.target.richValue = spans;

And my result is an empty text field.

I don’t know who to utilize the information you provided for my situation. Would it be possible for you to provide me with the coding?

Votes

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
community guidelines
Community Expert ,
Sep 28, 2017 Sep 28, 2017

Copy link to clipboard

Copied

I could but you wouldn't learn anything for next time.

Take a look at this link and then revisit the problem.

Learning to Program JavaScript for Adobe Acrobat - KHKonsulting LLC

Votes

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
community guidelines
Community Expert ,
Sep 28, 2017 Sep 28, 2017

Copy link to clipboard

Copied

LATEST

In the Acrobat JavaScript Reference look at the sample of the span object.

Votes

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
community guidelines