Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
Want you place the labels on all open documents?
Copy link to clipboard
Copied
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:
Copy link to clipboard
Copied
In the Action Wizard you can use:
global.DoPlaceDocNumbers(this),
Copy link to clipboard
Copied
I tried it but it did not work. It just labels the open document. Any other ideas?
Copy link to clipboard
Copied
No, I know nothing about your function.
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
In one action you can collect the docs in a global array. In a other action you can use this array.