Bold & justify text field text

Explorer ,
Nov 04, 2017

Copy link to clipboard

Copied

Hi, I have auto updating text field in my form second page. I’m updating first page field ”aa” & second page text filed auto updating..

I have used bellow code to manage that..

// Get field values

var one = getField('aa').value;

// Build para string

var para = "WHEREAS, pursuant to the transfer of the real property commonly known as " + one + ", by Assignee, Assignor wishes to assign and transfer all of its interest in the Lease Agreement(s) present or future to Assignee, and Assignee wishes to accept the foregoing Assignment from Assignor and assume all of the rights and obligations under the Lease Agreement(s) present and future;" ;

// Set this field's value equal to para

event.value = para;

what I want is,

  1. I want to justify the text in second page auto filling text field.
  2. I want to bold “"WHEREAS,” text.

I have already tried Ctrl +e option & it’s work. The issue is if I change first page “aa” value, second page auto filling text field, “Ctrl+e” all the settings automatically removing & just showing normal text. Can u pls help me to solve this issue. Thanks..

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

I don't think it's possible to achieve this justification using a script.

To apply the bold text use this:

var one = this.getField("aa").valueAsString;

var spans = [];

var span1 = {};

span1.fontWeight = 700;

span1.text = "WHEREAS";

spans.push(span1);

var span2 = {};

span2.text = ", pursuant to the transfer of the real property commonly known as " + one + ", by Assignee, Assignor wishes to assign and transfer all of its interest in the Lease Agreement(s) present or future to Assignee, and Assignee wishes to accept the foregoing Assignment from Assignor and assume all of the rights and obligations under the Lease Agreement(s) present and future;" ;

spans.push(span2);

event.richValue = spans;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

1.1K

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

Bold & justify text field text

Explorer ,
Nov 04, 2017

Copy link to clipboard

Copied

Hi, I have auto updating text field in my form second page. I’m updating first page field ”aa” & second page text filed auto updating..

I have used bellow code to manage that..

// Get field values

var one = getField('aa').value;

// Build para string

var para = "WHEREAS, pursuant to the transfer of the real property commonly known as " + one + ", by Assignee, Assignor wishes to assign and transfer all of its interest in the Lease Agreement(s) present or future to Assignee, and Assignee wishes to accept the foregoing Assignment from Assignor and assume all of the rights and obligations under the Lease Agreement(s) present and future;" ;

// Set this field's value equal to para

event.value = para;

what I want is,

  1. I want to justify the text in second page auto filling text field.
  2. I want to bold “"WHEREAS,” text.

I have already tried Ctrl +e option & it’s work. The issue is if I change first page “aa” value, second page auto filling text field, “Ctrl+e” all the settings automatically removing & just showing normal text. Can u pls help me to solve this issue. Thanks..

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

I don't think it's possible to achieve this justification using a script.

To apply the bold text use this:

var one = this.getField("aa").valueAsString;

var spans = [];

var span1 = {};

span1.fontWeight = 700;

span1.text = "WHEREAS";

spans.push(span1);

var span2 = {};

span2.text = ", pursuant to the transfer of the real property commonly known as " + one + ", by Assignee, Assignor wishes to assign and transfer all of its interest in the Lease Agreement(s) present or future to Assignee, and Assignee wishes to accept the foregoing Assignment from Assignor and assume all of the rights and obligations under the Lease Agreement(s) present and future;" ;

spans.push(span2);

event.richValue = spans;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

1.1K

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
Nov 04, 2017 0
Most Valuable Participant ,
Nov 04, 2017

Copy link to clipboard

Copied

1. What kind of justification?

2. This can be done using the Rich Text Formatting option. You need to enable that option for you field (which it sounds like you did already), and then apply an array of Span objects to the richValue property of the field, instead of applying a plain string to the value 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 04, 2017 0
Explorer ,
Nov 04, 2017

Copy link to clipboard

Copied

hi, thanks a lot for your reply. i have already enabled Rich Text Formatting. so u mean i have to update the code ?? i have found this code from adobe forum & used so is that possible to provide correct code?. thanks in advance..

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 04, 2017 0
Most Valuable Participant ,
Nov 04, 2017

Copy link to clipboard

Copied

Yes. You, or someone else, will need to update the code.

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 04, 2017 0
Explorer ,
Nov 04, 2017

Copy link to clipboard

Copied

hi, thanks. Justify mean all the text need to distribute evenly between the margins.. is that possible to provide correct code ?? i don't have idea about JavaScript & your help is much appreciating. thanks..

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 04, 2017 0
Most Valuable Participant ,
Nov 04, 2017

Copy link to clipboard

Copied

I don't think it's possible to achieve this justification using a script.

To apply the bold text use this:

var one = this.getField("aa").valueAsString;

var spans = [];

var span1 = {};

span1.fontWeight = 700;

span1.text = "WHEREAS";

spans.push(span1);

var span2 = {};

span2.text = ", pursuant to the transfer of the real property commonly known as " + one + ", by Assignee, Assignor wishes to assign and transfer all of its interest in the Lease Agreement(s) present or future to Assignee, and Assignee wishes to accept the foregoing Assignment from Assignor and assume all of the rights and obligations under the Lease Agreement(s) present and future;" ;

spans.push(span2);

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...
Nov 04, 2017 1
Adobe Community Professional ,
Nov 04, 2017

Copy link to clipboard

Copied

You can justify text in a rich text field but you can't use the standard Acrobat JS Span object to do it. Instead, you need to create the rich content using raw JSON so that you can use properties and values that Acrobat supports but didn't make it into the JavaScript API. See line 2...

var spans = [{

     alignment: "justify",

     fontFamily: ["Helvetica"],

     fontStyle: "normal",

     fontWeight: 400,

     text: "WHEREAS, pursuant to the transfer of the real property commonly known as \" + one + \", by Assignee, Assignor wishes to assign and transfer all of its interest in the Lease Agreement(s) present or future to Assignee, and Assignee wishes to accept the foregoing Assignment from Assignor and assume all of the rights and obligations under the Lease Agreement(s) present and future;",

     textColor: ["RGB", 0, 0, 0],

     textSize: 12

}]

this.getField("aa").richValue = spans;

If you want to see what to learn what's supported and how to express it in JSON, simply format the field using example data then in the console run...

this.getField("yourFieldName").richValue.toSource()

and the return value printed to the console will be a JSON object that represents the richValue. Then just edit it as you see fit programatically.

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 04, 2017 1
omanbux LATEST
Explorer ,
Nov 04, 2017

Copy link to clipboard

Copied

thanks lot for the both codes & both codes are working perfectly. combining that both codes, i have created bellow code & it's working. thanks again for the both codes. thanks..

var one = this.getField("aa").valueAsString; 

var spans = []; 

 

var span1 = {}; 

span1.fontWeight = 700; 

span1.text = "WHEREAS"; 

spans.push(span1); 

 

var span2 = {}; 

span2.alignment = "justify",

span2.text = ", pursuant to the transfer of the real property commonly known as " + one + ", by Assignee, Assignor wishes to assign and transfer all of its interest in the Lease Agreement(s) present or future to Assignee, and Assignee wishes to accept the foregoing Assignment from Assignor and assume all of the rights and obligations under the Lease Agreement(s) present and future;" ; 

spans.push(span2); 

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...
Nov 04, 2017 0