8 Replies Latest reply on Feb 29, 2012 1:43 AM by mediy

    Problems with richText / richValue

    mediy

      I hav created Form Fields with richText.

       

      Now I want to fill the Field with text of another richText Field.

       

      In Acrobat it works, but not in Reader.

       

      What might be the reason?

       

      Simple example:

       

      musterfeldname = "Mustertext_1"; // the (rtf-text)field to be read

      zielfeldname = "tBlock2_2"; // the (rtf-text)field to write to

       

      var f = getField(musterfeldname);

      var rtfinhalt = f.richValue;

              console.println("rtfinhalt: " + rtfinhalt);

       

      var g = getField(zielfeldname);

              getField(zielfeldname).value = "";   

              g.richValue = rtfinhalt;

       

      The original Text (rft text)  in "tBlock2_2" is destroyed, but no text will be displayed.

      In Reader, there is no error to be seen, but no console-window as well.

       

      (tested with AcroX, Reader 8)

       

      Thank you for any help...

        • 1. Re: Problems with richText / richValue
          try67 MVP & Adobe Community Professional

          Don't change the value property, just the richValue property.

          • 2. Re: Problems with richText / richValue
            mediy Level 1

            Thank you, try67.

             

            But this line

            getField(zielfeldname).value = "";

            is not the problem, I had it out of the script for testing yet.

             

            I'm a little confused, why does this script work correctly in Acrobat, but NOT in Reader?

             

            I do not understand, cause the following script does work in Reader (unfortunetly its not what i want...):

             

             

            //this part was taken from AcroJS Documentation and modifyed

             

             

             

            var spans = new Array();

            spans[0] = new Object();

            spans[0].text = "Attention:\r";

            spans[0].textColor = color.blue;

            spans[0].textSize = 18;

            spans[1] = new Object();

            spans[1].text = "Adobe Acrobat 6.0\r";

            spans[1].textColor = color.red;

            spans[1].textSize = 20;

            spans[1].alignment = "center";

             

            spans[2] = new Object();

            spans[2].text = "will soon be here!";

            spans[2].textColor = color.green;

            spans[2].fontStyle = "italic";

            spans[2].underline = true;

            spans[2].alignment = "right";

            // and now integrated into the original script

            musterfeldname = "Mustertext_1"; // the (rtf-text)field to be read

            zielfeldname = "tBlock2_2"; // the (rtf-text)field to write to

             

            var f = getField(musterfeldname);

            var rtfinhalt = f.richValue;// see the original code

                    console.println("rtfinhalt: " + rtfinhalt);

             

            var g = getField(zielfeldname);

                    getField(zielfeldname).value = "";   

                    g.richValue = spans; // not the value, I wanted to use, but working...

             

            Any more ideas????

             

             


            • 3. Re: Problems with richText / richValue
              try67 MVP & Adobe Community Professional

              I tested it in Acrobat and it worked... Don't know why it doesn't in Reader.

              Your file has the Form Rights enabled, right?

              • 4. Re: Problems with richText / richValue
                mediy Level 1

                Yes, Form Rights are enabled...

                • 5. Re: Problems with richText / richValue
                  try67 MVP & Adobe Community Professional

                  Are you getting any error messages in Reader?

                  • 6. Re: Problems with richText / richValue
                    mediy Level 1

                    No error messages to be seen, no console-window is opening...

                    • 7. Re: Problems with richText / richValue
                      mediy Level 1

                      So, now I'm not quite sure, but I think, the cause might be the name of the Array

                       

                      I changed the name in my 1st Example from

                       

                      "rtfinhalt"

                      to

                      "span"

                       

                      And now, for my surprise, it seems to work!

                      (some more testing necessary...)

                       

                      Is it possible, that only the array-name "span" is supported for this feature, when using enabled form rights?

                       

                      Thank you, try67, often discussions help to solve problems!!!!

                       


                       


                      • 8. Re: Problems with richText / richValue
                        mediy Level 1

                        Some more tests did not prove true my idea with the Array-name...

                         

                        But I found a dirty work-around.

                        For testing, I created a button, that generated a rtf-form-field. That works, as I tested before.

                        For my surprise, after klicking to that button, all my other rtf-form fields where filled correctly in Reader, like using AcroPRo!

                         

                        So I created a DocJS, that creates a rtf-text-field, populates it with any text, and directly after deletes the field.

                         

                        And now my script works properly.

                         

                        What a nonsense!

                         

                        May be, that work-around could help anyone else.

                         

                        Does someone have an explanation?

                         

                        But I am happy now...