Copy link to clipboard
Copied
I have an action script to create a report listing the document file names from multiple pdf files.
The script is creating multiple reports for each pdf file, instead of appending each document file name in the single report.
If anyone can help to amend the script so that a single report is created will be most appreciated
// Begin job
var docfile = this.documentFileName;
if ( typeof global.counter == "undefined" )
{
global.counter = 0;
}
// Main code to process each of the selected files
try {
global.counter++
global.report = new Report()
global.report.writeText("Report on File \#"+global.counter + docfile + "\r\n");
global.report.open("job report")
} catch(e) {
console.println("Batch aborted on run #" + global.counter);
delete global.counter; // Try again, and avoid End Job code
event.rc = false; // Abort batch
}
// End job
if ( global.counter == global.FileCnt ) {
console.println("End Job Code"); /
/ Insert endJob code here
// Remove any global variables used in case user wants to run
// another batch sequence using the same variables
delete global.counter;
}
This is what I used for most of the Action scripts I created on this page:
https://acrobatusers.com/actions-exchange
Rick Borstein hired me to create them, so look at all the ones with his name.
try{global.oBkmkSumDoc.path;}
catch(e)
{
global.oBkmkSumDoc = new report();
.. Build report doc.
}
Usually there is also a custom dialog that is displayed at the same time the new report is created. The important bit here is that accessing the properties of a dead object will throw an exception. So if the rep
...Copy link to clipboard
Copied
Try this:
if (global.counter == 1) global.report = new Report();
Copy link to clipboard
Copied
This is what I used for most of the Action scripts I created on this page:
https://acrobatusers.com/actions-exchange
Rick Borstein hired me to create them, so look at all the ones with his name.
try{global.oBkmkSumDoc.path;}
catch(e)
{
global.oBkmkSumDoc = new report();
.. Build report doc.
}
Usually there is also a custom dialog that is displayed at the same time the new report is created. The important bit here is that accessing the properties of a dead object will throw an exception. So if the report file does not exist, it will be created and the initial setup params dialog will be displayed. If it does exist, then anything new that happens will be added to it.
Keeping parameters like a report count are unreliable. There is no way to know if something outside your Action is affecting parameters like a global.counter, so it is unreliable. But a pointer to the report document is very direct and reliable. It either exists or is doesn't.
In my setup the report document is completely built and then the dynamic data from the batch process is collected into form fields. I think it's a bad idea to leave a report object hanging between batch operations. There is literally no way to know when the Batch process is finished, unless you require the use to hit some kind of finish button.
Copy link to clipboard
Copied
Thank you very much Thom.
Downloaded the Create Comment Summary script from Actions exchange.
I have adapted the part of this action that creates a new document and lists all document file names from multiple pdf files.
This is a very impressive action with a detailed amount of scripting, well done.