7 Replies Latest reply on Nov 4, 2017 8:02 PM by omanbux

    Bold & justify text field text

    omanbux Level 1

      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..

        • 1. Re: Bold & justify text field text
          try67 MVP & Adobe Community Professional

          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.

          • 2. Re: Bold & justify text field text
            omanbux Level 1

            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..

            • 3. Re: Bold & justify text field text
              try67 MVP & Adobe Community Professional

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

              • 4. Re: Bold & justify text field text
                omanbux Level 1

                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..

                • 5. Re: Bold & justify text field text
                  try67 MVP & Adobe Community Professional

                  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;
                  
                  • 6. Re: Bold & justify text field text
                    Joel_Geraci Adobe Community Professional

                    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.

                    • 7. Re: Bold & justify text field text
                      omanbux Level 1

                      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;