Highlighted

Fillable PDF form Field will not bold when I exit out

New Here ,
Oct 30, 2020

Copy link to clipboard

Copied

I have a fillable PDF form field that has "allow rich text formatting" turned on, but when I click out of the field it un-bolds. I have a calculation script on there and a validation script and I'm not sure if that's why it's not working because all other fields without that will BOLD. I'm not sure how to get it to stay bold.

TOPICS
General troubleshooting, PDF forms

Views

42

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

Fillable PDF form Field will not bold when I exit out

New Here ,
Oct 30, 2020

Copy link to clipboard

Copied

I have a fillable PDF form field that has "allow rich text formatting" turned on, but when I click out of the field it un-bolds. I have a calculation script on there and a validation script and I'm not sure if that's why it's not working because all other fields without that will BOLD. I'm not sure how to get it to stay bold.

TOPICS
General troubleshooting, PDF forms

Views

43

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
Oct 30, 2020 0
Most Valuable Participant ,
Oct 30, 2020

Copy link to clipboard

Copied

Yes. The calculation script overwrites the value you enter into it manually. You can't have it both ways...

In order for it to be bold you need to apply an array of Span objects in the calculation script to event.richValue and specify the fontWeight so the text appears as bold.

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...
Oct 30, 2020 0
New Here ,
Oct 30, 2020

Copy link to clipboard

Copied

I see! That makes sense. I tried if
(event.value>18)
event.value=18
event.richValue700;

But it's not coming out. Do you know what I'm doing wrong?

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...
Oct 30, 2020 0
Adobe Community Professional ,
Oct 30, 2020

Copy link to clipboard

Copied

Rich text is created by using the Span object. Here's the entry in the JavaScript Reference:

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_Acro...

 

The "richValue" of a field is composed of an array of span objects. Each span represents text in a specific style. For calculated field there is only one span. So to bold a calculated value you have to set the "fontWeight" property of this single span.

 

Add this code to the bottom of the calculation script

 

 

spans = event.richValue
spans[0].fontWeight = 900
event.richValue = spans

 

 

 

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...
Oct 30, 2020 0
New Here ,
Oct 30, 2020

Copy link to clipboard

Copied

This script is in the valdition section and it didn't bold it. I typed:

 

if (event.value>18)

event.value=18;
spans = event.richValue
spans[0].fontWeight = 900
event.richValue = spans

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...
Oct 30, 2020 0
Adobe Community Professional ,
Oct 30, 2020

Copy link to clipboard

Copied

Ahh, I see what is happening. It appears that setting the uncommitted value (event.value) decouples the rich value from the process.  So we have to work purely in the rich value.

Try this:

 

spans = event.richValue;
if (event.value>18)
    spans[0].text="18";

spans[0].fontWeight = 900;
event.richValue = spans;

 

Notice how every line ends with ";" and the line after the "if" is indented. It helps is you properly format the code. Especially when posting for other people to read. 

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...
Oct 30, 2020 0
New Here ,
Oct 30, 2020

Copy link to clipboard

Copied

I copy and pasted it and now it's even going over 18%. It should aways stay at 18% max, and it did not bold. It's okay though, i'll just have to go with these few text fields not bold. Thank you 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
Reply
Loading...
Oct 30, 2020 0
Most Valuable Participant ,
Oct 30, 2020

Copy link to clipboard

Copied

Try this code:

 

if (event.richValue) {
	var spans = event.richValue;
	if (Number(spans[0].text)>18)
		spans[0].text="18";

	spans[0].fontWeight = 900;
	event.richValue = spans;
}

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...
Oct 30, 2020 0
New Here ,
Oct 30, 2020

Copy link to clipboard

Copied

I is still unfortunately the same. 😞 

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...
Oct 30, 2020 0
Adobe Community Professional ,
Oct 30, 2020

Copy link to clipboard

Copied

What font is the field using?

 

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...
Oct 30, 2020 0
Most Valuable Participant ,
Oct 30, 2020

Copy link to clipboard

Copied

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...
Oct 30, 2020 0
Adobe Community Professional ,
Oct 30, 2020

Copy link to clipboard

Copied

My code worked fine as well. I think there must be something beyond the validation script. Maybe a formatting script. Or an odd font that won't bold. 

 

 

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...
Oct 30, 2020 0
New Here ,
Nov 02, 2020

Copy link to clipboard

Copied

I am trying to bold all the fields with an interest rate in them. Please see below, I pasted the script into VARIABLE_INT_RATE_CA FIELD. 

 

https://drive.google.com/file/d/1UrGHdge21g9Xev2hjrCcpRnHbXRhniwS/view?usp=sharing

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 02, 2020 0
Most Valuable Participant ,
Nov 02, 2020

Copy link to clipboard

Copied

This is the link I posted...

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 02, 2020 0
New Here ,
Nov 02, 2020

Copy link to clipboard

Copied

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 02, 2020 0
Most Valuable Participant ,
Nov 02, 2020

Copy link to clipboard

Copied

You must set the field as having Rich Text Formatting. To be honest, though, I don't understand why you're doing this with a script. Just set the field to use a Bold font, and that's it... Even if you want to make it conditional there are easier ways of doing it, like changing the textFont property.

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 02, 2020 0
New Here ,
Nov 02, 2020

Copy link to clipboard

Copied

I can't set the field to bold, the other person said i can't have it both
ways. I don't care how I do it, I just want to bold those fields and it
hasn't been working. Did it work when you tried to bold those fields?

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 02, 2020 0
Most Valuable Participant ,
Nov 02, 2020

Copy link to clipboard

Copied

That was me, and it had nothing to do with it being bold. I was referring to it not being able to have both a calculated value and allow the user to enter a value into it at the same time.

Just go to Properties, Appearance and select a bold variant of the font you want to use, like "Helvetica Bold".

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 02, 2020 0
New Here ,
Nov 02, 2020

Copy link to clipboard

Copied

WOW, talk about inexperience on my part! It worked, thank you so much. I was definitely overcomplicating things.

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 02, 2020 0