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

How to make font to fix text box automatically

New Here ,
Jan 13, 2021 Jan 13, 2021

Copy link to clipboard

Copied

Hello, I need help with making an interactive PDF.

I'm new to this so I'm not sure how much of this is possible to do, but I would appreciate some help!

 

1) I need the font size in both left and right boxes to be set at 14pt and then to gradually reduce to fit the size of the box depending on the amount of text. 

finny99_0-1610593159459.png

2) I would also like the text on the right hand column to be Red and 14pt font, unless the first word is "Perfect." the word perfect should be this shade of blue. Or for the box to automatically show a blue "Perfect." if the Grade is "A" (not sure which is easier to do).

 

Thank you in advance! 

TOPICS
Acrobat SDK and JavaScript

Views

171

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
community guidelines
Community Expert ,
Jan 14, 2021 Jan 14, 2021

Copy link to clipboard

Copied

1) You can't do it "gradually" while the text is filled in, unless you set the font size to Auto. You can set the font size after the text was entered to a desired value, based on its length, though.

2) Changing the color of a single word in a field is possible, but complicated. It requires setting it up as a Rich Text Formatted field and then applying the value as an array of Span items (two, in this case).

The second option you mentioned is much easier to implement, and can be done via the Validation event of the Grade field.

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
community guidelines
New Here ,
Jan 14, 2021 Jan 14, 2021

Copy link to clipboard

Copied

1) If I set it to Auto, can I set it so that it always begins with 14pt?

2) Could you talk me through the second option (validation event of the grade field)? 

 

And I've run into another problem, if you could help me with that, I would appreciate it!

If the sentence starts with Suggested Answer : ,  to have those first two words and the colon to be italicized.

 

Thank you so much for your help!

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
community guidelines
Community Expert ,
Jan 14, 2021 Jan 14, 2021

Copy link to clipboard

Copied

1. No.

2. Add this as the custom validation script of the Grade field (let's say the feedback field is called "Feedback1"):

 

var f = this.getField("Feedback1");
if (event.value=="A") {
	f.value = "Perfect";
	f.textColor = color.red;
} else {
	f.value = "";
	f.textColor = color.black;
}

 

3. This requires the same kind of complicated solution as having only one word in a different color than the rest of the 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
community guidelines
New Here ,
Jan 14, 2021 Jan 14, 2021

Copy link to clipboard

Copied

Hello, thank you again for your help!

It doesn't seem to be changing the font color for me. What could I be doing wrong? I changed the field name to the field with the letter grade. 

 

var f = this.getField("1Grade1");
if (event.value=="A") {
f.value = "Perfect";
f.textColor = ["RGB", 0, 0.5, 1]
} else {
f.value = "";
f.textColor = color.black;
}

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
community guidelines
Community Expert ,
Jan 15, 2021 Jan 15, 2021

Copy link to clipboard

Copied

The code seems fine. So after you select something that's not A and enter some text into the field, it's not in black?

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
community guidelines
New Here ,
Jan 17, 2021 Jan 17, 2021

Copy link to clipboard

Copied

Hello,

Yes, below is a screenshot.

finny99_1-1610951493029.png

> 1Grade1 shows A. The text is still red.

finny99_3-1610951594969.png

 

Thank you!

 

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
community guidelines
Community Expert ,
Jan 17, 2021 Jan 17, 2021

Copy link to clipboard

Copied

You change the color of field "1Grade1", not "1F1".

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
community guidelines
New Here ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

LATEST

Sorry, I think I'm a little lost. But it also turned out that "A" isn't always "Perfect" on the grading scale, so I need to edit the form again. I think I'll post them on a separate post. I appreciate your help! 

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
community guidelines
New Here ,
Jan 20, 2021 Jan 20, 2021

Copy link to clipboard

Copied

I ran into a similar problem, so thanks for the help!

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