2 Replies Latest reply on Feb 8, 2016 9:46 AM by JonathanG242

    Is there a Java command/script that will run all calculations in a PDF on document open?

    JonathanG242

      Long story short, designing a time sheet for my company using Adobe Pro. The form has some fields that use java script to calculate different values. For example when someone enters in the week ending date it populates the rest of the form with the correct days. It's a simple script that is located in "custom calculation". It works fine on PC, and iOS devices (when using a PDF reader app) but does not calculate when on Android devices. When it is then opened on a PC the dates have not calculated. This appears to be a problem with the Android device and the way it handles scripts embedded in the page. For testing I used Adobes PDF reader program so in theory those functions should be enabled. I however can find very little information on to why this would happen. For me a simple work around would be to set the document properties to just run all the calculations on the page on open. So when it's opened on a PC by our payroll department the dates will populate. If you are curious of the code I'm using I've attached it below. 

       

      Thank you in advance.

       

       

      The script:

       

      // Custom Calculate script for text field 

      (function () { 

       

          // Get ZZWEEKEND field value 

          var v = getField("ZZWEEKEND").value; 

       

          // If field is empty, blank this field 

          if (v === "") { 

              event.value = v; 

              return; 

          } 

       

          // Convert the date string to a date object 

          var d = util.scand("mm/dd/yyyy", v); 

       

          // Subtract Number of days 

          d.setDate(d.getDate() - 4); 

       

          // Set this field's value 

          event.value = util.printd("mmm-dd", d); 

       

      })();