Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How call multiple pdf's

Explorer ,
May 22, 2017 May 22, 2017

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)

TOPICS
Acrobat SDK and JavaScript , Windows
984
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 22, 2017 May 22, 2017

Want you place the labels on all open documents?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 23, 2017 May 23, 2017

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:

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2017 May 23, 2017

In the Action Wizard you can use:

global.DoPlaceDocNumbers(this),

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 23, 2017 May 23, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2017 May 23, 2017

No, I know nothing about your function.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 23, 2017 May 23, 2017

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 24, 2017 May 24, 2017

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).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 24, 2017 May 24, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 24, 2017 May 24, 2017

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);

        }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 06, 2017 Jun 06, 2017
LATEST

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 24, 2017 May 24, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines