11 Replies Latest reply on Jun 6, 2017 6:31 PM by sargums46564804

    How call multiple pdf's

    sargums46564804 Level 1

      Hi,

       

      I have a variable called ODoc which is the current pdf and calls a global function which places a label on it based on input into a dialogue (code not shown):

       

       

      var oDoc = event.target;  

              global.DoPlaceDocNumbers(oDoc)

       

       

      However, I would like it to call all the pdf's in the batch so the labels can be applied all at the same time.

       

      I have posted this question before and received an answer about calling all the pdf's at once and then performing the action.  I have been researching this to see if there is an "event.all" (or something similar) which I did not see and then tried using a for loop to accomplish this but have not been successful:

       

       

      var oDoc = event.target;

      for (var i=0; i<oDoc; i++)

      global.DoPlaceDocNumbers(oDoc)

        • 1. Re: How call multiple pdf's
          Bernd Alheit Adobe Community Professional & MVP

          Want you place the labels on all open documents?

          • 2. Re: How call multiple pdf's
            sargums46564804 Level 1

            All the documents would not be open.  They would have been selected as a part of the batch record selection of the action wizard. Only the 1st document would be opened to initiate the action wizard.

             

            Selection of Documents:

             

            Action Wizard Steps:

            • 3. Re: How call multiple pdf's
              Bernd Alheit Adobe Community Professional & MVP

              In the Action Wizard you can use:

               

              global.DoPlaceDocNumbers(this),

              • 4. Re: How call multiple pdf's
                sargums46564804 Level 1

                I tried it but it did not work.  It just labels the open document.  Any other ideas?

                • 5. Re: How call multiple pdf's
                  Bernd Alheit Adobe Community Professional & MVP

                  No, I know nothing about your function.

                  • 6. Re: How call multiple pdf's
                    sargums46564804 Level 1

                    I think a simpler way of asking this is how do I collect all docs (e.g., pdf1, pdf2, pdf2, etc.) and save them as global variables? Can you show me a simple example? Right now, the javascript only runs on event.target (or current document).

                    • 7. Re: How call multiple pdf's
                      Test Screen Name Most Valuable Participant

                      We shouldn't need to guess what you are doing to answer your question!

                       

                      When you do an action, a piece of script is run for each file separately. You want to run a dialog once? Run it the first time and set a global flag (but expect to have to quit Acrobat to clear the global flag).

                      • 8. Re: How call multiple pdf's
                        Test Screen Name Most Valuable Participant

                        By the way, I guess you might be refusing to include your script either because it is sensitive - this is wise - or because it is large - this is good because we won't read a big script.

                         

                        The solution is to make a very, very short similar script which has the same sort of effect and issues and show us that.

                        • 9. Re: How call multiple pdf's
                          Bernd Alheit Adobe Community Professional & MVP

                          In one action you can collect the docs in a global array. In a other action you can use this array.

                          • 10. Re: How call multiple pdf's
                            sargums46564804 Level 1

                            Per the suggestion, here is a stripped down version of the script where I tried to make it still execute the labeling function even when the dialogue is not evoked again (see blue txt).  Why?  B/c I don't want the user to have to click the "ok" button for each pdf to apply the label.  I just want the user to click "ok" once and then it labels all the pdf's (pdf 1, pdf 2, pdf 3, etc.) which were selected in the action.

                             

                            //Function DocNumActionDlg

                              var DoNumActionDlg = app.trustedFunction(function()      //Opens dialogue where "ok" button to apply label exists

                              {

                               app.beginPriv();

                               return app.execDialog(global.DocNumAction);

                               app.endPriv();

                               });

                             

                            //Function DoPlaceDocNumbers (labels Label Content, doc num, and pages numbers for each document)

                               global.DoPlaceDocNumbers = app.trustedFunction(function(oOrigDoc)

                            .

                            .// Setup

                                var oDoc = event.target;               //current pdf document (SCS)

                                var cRtn = DoNumActionDlg();      //Dialogue with"ok" button to apply labels.

                                   

                                 if ("ok" == cRtn)                            //if user clicks "ok" initiates DoPlaceDocNumbers funtion (above) on current pdf

                                    {

                                     //Setup Initial Doc Number

                                      if(global.DocNumAction.bIncludePageNum)

                                       

                                        global.DoPlaceDocNumbers(oDoc);

                             

                                     //Increment Doc Number if applicable so can get ready for next pdf document as loops again

                                      if(global.DocNumAction.bIncludeDocNum)

                                       {

                                       global.DocNumAction.nCurrentDocNum++;

                                     

                                       }

                                    }

                             

                                  else if "ok" != cRtn)  //Here is where i need help b/c this statement does not work. If code sees no dialogue (which I did on purpose), I still want it to label subsequent pdf's.

                                   global.DoPlaceDocNumbers(oDoc);

                                    }

                            • 11. Re: How call multiple pdf's
                              sargums46564804 Level 1

                              figured this out.  I have to call the action on the hidden files and then it bypasses the dialogue:

                               

                              if (this.hidden)

                                    {

                                global.DoPlaceDocNumbers(this);

                                global.DocNumAction.nCurrentDocNum++;

                                      global.DocNumAction.strInitDocNum = global.DocNumAction.nCurrentDocNum.toString();

                                      }

                              else

                                  // Setup

                                  {var oDoc = event.target; //current pdf document (SCS)