4 Replies Latest reply on Mar 19, 2016 3:40 PM by lacostal

    Javascript Issues When Delivering to Client Using Acrobat Reader XI

    lacostal

      I am working on a form for a client that essentially takes a table of radio button values, applies a weighted percentage to them, and creates a score for each row in the table. The score is then tallied at the end of each of two tables. Ultimately, those two scores get averaged in the final row on page two and a result "Complete Action A" or "Complete Action B" shows up in a text field next to the score. The entire thing is working beautifully after multiple revisions. Or rather, it's working beautifully in DC Pro and DC Reader. When I send to the client who is using Reader XI, the last row (the if/then script for the average of the two scores and the text action) are not calculating at all. Any help would be appreciated. This is all confidential work for a client so I cannot post the actual file, but can share code snippets for the java.

        • 1. Re: Javascript Issues When Delivering to Client Using Acrobat Reader XI
          gkaiseril MVP & Adobe Community Professional

          PDFs use JavaScript for coding and not the Java language.

           

          This will all be done with custom JavaScript code placed in the PDF. Without the exact field names is pretty hard to provide any code since the field objects will be needed to be accessed.

           

          Have you opened the Acrobat JavaScript console to see if there are any errors?

           

          Have you checked the order of the fields used in the calculation?

           

          It might be possible the user is not completing the form as you have assumed.

          • 2. Re: Javascript Issues When Delivering to Client Using Acrobat Reader XI
            lacostal Level 1

            I'm aware of the JavaScript. I apologize for the "typo" as I used the word Java instead of JavaScript. End of a very long day.

             

            That said, I have checked the order of the fields in the calculation and they are in proper order and the console is not showing errors.

             

            There are about four primary custom JavaScript components on the page. All of them are if/then except one. So, the other if/then statements that null the field if it is empty are working, but the last two fields are not. This is not happening in DC Pro and Reader. It is only happening in Reader XI. 

             

            Sample 1 - Not Working in Reader XI:

            (function () {

                var y = getField("Score1").value;

                var x = getField("Score2").value;

             

                if (n => 0.000)
                      {event.value = (y+x)/2;}

                else if (n <= 0.000)

                     {event.value = "";}

            })();

             

            Sample 2 - Not Working in Reader XI:

            (function () {

                 var q = this.getField("AScore").valueAsString;

             

                 if (q <= 0.001)

                      {event.value = "";}

                 else if (q <= 3.3999)

                      {event.value = "Complete A";}

                 else if (q => 3.4000)

                      {event.value = "Complete B";}

            })();

            • 3. Re: Javascript Issues When Delivering to Client Using Acrobat Reader XI
              try67 MVP & Adobe Community Professional

              Neither of these scripts should work in Acrobat nor in Reader, because they contain multiple syntax errors.

              First of all, you're using an invalid operator, namely "=>". You should be using ">=".

              In addition you have 2 other errors that I can spot. In the second script you're using the valueAsString property but then you're treating what it returns (the "q" variable) as a number. It's not, it a string. So what you should be doing is converting it to a number, like this:

              var q = Number(this.getField("AScore").valueAsString);

              And in the first script you're using a variable which you never declared ("n").

               

              If you fix these issues it should work in both Acrobat and Reader.

              • 4. Re: Javascript Issues When Delivering to Client Using Acrobat Reader XI
                lacostal Level 1

                Thank you. I should have caught the errors. I admittedly am not a pro at JavaScript for PDF. I am running the test again on XI. Working in DC. I'm double checking everything at the moment to ensure that I didn't miss anything else. Moving really fast on this one and I'm sure I missed more than what you caught.