2 Replies Latest reply on Oct 15, 2010 1:55 PM by Ranjaxt2012

    Call Trusted function insidd another function.

    Ranjaxt2012

      Note: - In simple word all i want to do is to use different functions inside a function to improve the speed of my script.

       

      i have been reading through Adobe document since last a few days, but couldn't find answer to use object name "getPageNumWords" inside my trusted function. adobe script just simply does not recognize "this" object when it is inside trusted function. I understand that i have to use some document object but how, i am not sure. can someone please help me with this issue.

       

      //---------------------------------------------------------------------------------------- -----------

       

      var mytestfunc = app.trustedFunction(function()
      {
      app.beginPriv();

      apnumWords = this.getPageNumWords(1); //for page # 2

       

              for (var z = 0; z < apnumWords; z++)
                             {
                  apWord = this.getPageNthWord(1,z);

       

                     if (apWord == "Model")
                     {

                  app.alert("The text is " + myWordFound)
                      }

       

                              }

       

      }
      app.endPriv();

       

      });

       

      //---------------------------------------------------------------------------------------- -----------

       

      var myfunccheck = app.trustedFunction(function()
      {
      mytestfunc();
      });

       

      //---------------------------------------------------------------------------------------- -----------

      app.addMenuItem({cName:"AMM Linker",cParent:"Tools",cExec:"myfunccheck()"});

       

       

      reff

      http://acrobatusers.com/forum/embeded-trusted-functions-function-embeded-functions#comment -71413

        • 1. Re: Call Trusted function insidd another function.
          George_Johnson MVP & Adobe Community Professional

          The problem is the object that "this" references is not the document object in folder-level JavaScripts. You should pass a reference of the document object when you call a folder-level JavaScript and instead of using "this" in your code, use the document object that was passed to the function. There is some sample code in the Acrobat JavaScript reference that demonstrates this.

          1 person found this helpful
          • 2. Re: Call Trusted function inside another function.
            Ranjaxt2012 Level 1

            i got it thanks, now how my function can through a value and how can my other function accept the value.

             

            in simple function 1 & 2 through a value and function 3 uses them to create a link.

             

            app.addMenuItem({cName:"Linker",cParent:"Tools",cExec:"mycheck_3()"});

             

            function mycheck_3 (doc)
                 {

            //my function mycheck_3 is creating link.

            //i want to use these key words to create link around my subject.

             

            apWord_mycheck_1 + apWord_mycheck_2)

             

            }

             

            function myfinalfunction()

             

            {

             

            app.trustedFunction(mycheck_1(this));

             

            app.trustedFunction(mycheck_2(this));

             

            app.trustedFunction(mycheck_3(this));

             

            }

             

            function mycheck_1 (doc)
                {
            var apWord_mycheck_1, apWord2, apnumWords;

             

                apnumWords = doc.getPageNumWords(1);

             

                    for (var z = 0; z < apnumWords; z++)
                    {
                        apWord_mycheck_1 = doc.getPageNthWord(1,z);

             

                        if (apWord_mycheck_1 == "Model_1")
                        {

            //how to through out apWord_mycheck_1 ?????
                            }

             

                                    }

             

                    }
                }

             

            function mycheck_2 (doc)
                 {
            var apWord_mycheck_3 =

            function mycheck_2 (doc)
                 {
            var apWord_mycheck_2, apWord2, apnumWords;

             

                apnumWords = doc.getPageNumWords(1);

             

                    for (var z = 0; z < apnumWords; z++)
                     {
                         apWord_mycheck_2 = doc.getPageNthWord(1,z);

             

                        if (apWord_mycheck_2 == "Model_2")  
                         {

            //how to through out apWord_mycheck_2 ?????
                             }

             

                                    }

             

                    }
                 }