3 Replies Latest reply on Mar 30, 2012 6:40 PM by frameexpert

    Building calculators using scripting

    garyhatt Level 1

      I have technical manuals that have many formulas within them. I am looking at creating calculators in Frame 10, so that in the PDF, they can just fill in the correct numbers and the answers will be calculated. The formulas may range from fairly simple, to complex.




      A – 23" divided by B – 4" = 5.75

      1/2 the load = 1,000 pounds

      1,000 x 5.75 = 5,750 pounds

      Answer — 5,750 pounds.


      Would want it to look like below in Frame. Where they would fill in A, B and Load information, and Tension on Sling would be calculated.



      (Enter numbers in boxes below):

      A = ____ B = ____ Load = ____

      Tension on Sling = ____



      Something more complicated might look like this:

      To determine the load on Block B, use the following formula:

      (LOAD L2 + 10%) × 1.41 (Sheave Angle Factor) = Load on Block B

      (2,200 lbs. + 220) × 1.41 = 3,412 lbs.



        • 1. Re: Building calculators using scripting
          Milo G Level 1

          I'm still relatively new to scripting FrameMaker, but I would think this would be MUCH easier to do in the resulting pdf using Acrobat. There you can create basic math functions (which this appears to be) with little more than point-and-clicks. If this turned out to be beyond the absolute basics, then a simple JavaScript can be applied to the Tension field.





          • 2. Re: Building calculators using scripting
            frameexpert Level 4

            Hi Gary,


            This is definitely possible; in fact, I am working on a project like this right now. I am using Microtype's TimeSavers and FormAssist (http://www.microtype.com), which allow you to embed pdfmark commands in FrameMaker Hypertext markers. When the FrameMaker file is distilled, the live area of each marker becomes an Acrobat form field based on the marker's specifications. The advantage here is that the form data is part of the FrameMaker file and doesn't have to be added manually everytime you make a new PDF. Here is an example of one of the marker's syntax, which creates a calculating field in the PDF:



            alert ~NC (calc.WBLF_MomentTakeoffCondtion) /^^2s-Jh1-Va () 2

              /JS (var f1=getField("calc.WBLF_MomentSubtotal2");

              var f2=getField("WBLF_MomentFuelStartup");

              event.value=(Math.round((f1.value-f2.value) * 100) / 100)) (2) /l


            I have added line feeds for clarity. Here is a brief explanation of the components:


            ~NC denotes a numeric field that performs a calculation.

            (calc.WBLF_MomentTakeoffCondition) denotes the field name in the PDF.

            /^^2s-Jh1-Va is a set of codes that determines the appearance of the field in the PDF.

            () is where you could enter a tool tip value for the field; in this case, it is blank.

            2 is the calculation order for the field.

            /JS (...) is the JavaScript code that is executed when the field is calculated.

            (2) is the number of decimal places for the field.

            /l is the alignment of the numbers in the field; in this case, left.

            Of course, all of these options are explained in the FormAssist (and TimeSavers) documentation.

            To streamline the entering of the markers in various FrameMaker tables and anchored frames, I use a set of custom FrameScript scripts that I wrote (http://www.framescript.com).

            I would be glad to show you a demonstration of the process so you can see what is involved. I am very happy with the process and find it amazing that you can basically create forms with FrameMaker, and get fully-functioning Acrobat forms in the resulting PDFs. Please let me know if you have any questions or comments.

            Rick Quatro

            • 3. Re: Building calculators using scripting
              frameexpert Level 4

              Hi Milo,


              The problem with adding fields in Acrobat is that it is fairly labor intensive and has to be redone whenever you need to make a new PDF from your FrameMaker document. The Microtype solution is much better because the form information is added to the FrameMaker document and you get the Acrobat forms automatically when you distill the FrameMaker document.