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

Need a format javascript to bold first line of a text box in interactive PDF

Community Beginner ,
Apr 14, 2020 Apr 14, 2020

Hi everyone,

 

I created an interactive text box (Arial regular) to let the client fill by themselves, in which the first paragraph needs to be bold.

I know I can change it into the rich-text format and press ctrl+B to get bold text, but the client asks me to try.

Any ideas can help me?

 

Thank you.

TOPICS
PDF forms
3.4K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Apr 16, 2020 Apr 16, 2020

You can use this code as the custom validation script of your field:

 

var v = event.value;
var lines = v.split("\r");
var spans = [];
for (var i=0; i<lines.length; i++) {
	spans.push({text: lines[i]+"\r", fontWeight: (i==0) ? 800 : 500});
}
event.richValue = spans;

View solution in original post

Translate
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 ,
Apr 15, 2020 Apr 15, 2020

You can use a validation script to change the first line of the text they enter to bold, but it will only happen once they leave the field.

Translate
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 ,
Apr 15, 2020 Apr 15, 2020

That ok! can you please give me that script~

More tutorials are awesome!

Translate
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 ,
Apr 16, 2020 Apr 16, 2020

You can use this code as the custom validation script of your field:

 

var v = event.value;
var lines = v.split("\r");
var spans = [];
for (var i=0; i<lines.length; i++) {
	spans.push({text: lines[i]+"\r", fontWeight: (i==0) ? 800 : 500});
}
event.richValue = spans;
Translate
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 ,
Apr 21, 2020 Apr 21, 2020

Sorry for the late response!
The first thing is to thank you for your help, but somehow your code works really well, the reason I say "somehow" is because only some pdf files work with this code.

I don't know why but when I added this code it jumped to "held value is not validated", even if they all have the same size, font, setting, format.

Do you have any idea?

Thank you.

Translate
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 ,
Apr 21, 2020 Apr 21, 2020

Make sure the option for Rich Text Formatting is selected.

Translate
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 ,
Apr 21, 2020 Apr 21, 2020

I always choose that option, because when sending it to customers, I need to bold the first line anyway.

Translate
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 ,
Apr 22, 2020 Apr 22, 2020

Can you share the actual file with us? You can attach it to the original message using the tiny paperclip icon at the bottom when you edit it, or upload it to a file-sharing website (like Dropbox, Google Drive, Adobe Cloud, etc.), generate a share link and then post it here.

Translate
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 ,
Oct 14, 2021 Oct 14, 2021

Hi all,

 

I'm looking for a similar script but then one which makes all text bold in a interactive PDF text box.

Can anyone help me on this one?

 

Thanks.

 

 

Translate
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 ,
Oct 14, 2021 Oct 14, 2021
LATEST

You don't need a script to do this, if you want all the text in bold just select a bold font in the Appearance attributes.


PDF Acrobatic, InDesigner & Photoshoptographer
Translate
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