Call Actions (Sequences) from Another Actions

Jul 31, 2017

Copy link to clipboard

Copied

Hi,

     I need to call one action from another action. How can I call action from javascript code?? For eg.,

     The following code is a general outline of how you can insert Begin Job and End Job code: it uses global.counter to detect the beginning of the job and uses another global variable global.FileCnt, which is set earlier by another batch sequence that counts the number of files to be processed, see Count PDF files, to detect the end of the job.

ACTION 1:  Count PDF Files Sequence Code

/* Count PDF files */

if ( typeof global.FileCnt == "undefined" ) global.FileCnt = 0;

global.FileCnt++

ACTION 2 : Begin and End job code for batch process

// Begin job

if ( typeof global.counter == "undefined" ) {

     console.println("Begin Job Code");

     global.counter = 0;

     // insert beginJob code here

     ................

}

// Main code to process each of the selected files

try {

     global.counter++

     console.println("Processing File #" + global.counter);

     // insert batch code here.

     ...............

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

}

I got the above code when I searching.  In that they have said need to call Count PDF Files action before call Begin and End job Action.  But I don't how to call.  Can anyone help to how to merge these two sequences??

- Sudha K

TOPICS
Acrobat SDK and JavaScript

Views

733

Likes

Translate

Translate

Report

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

Call Actions (Sequences) from Another Actions

Jul 31, 2017

Copy link to clipboard

Copied

Hi,

     I need to call one action from another action. How can I call action from javascript code?? For eg.,

     The following code is a general outline of how you can insert Begin Job and End Job code: it uses global.counter to detect the beginning of the job and uses another global variable global.FileCnt, which is set earlier by another batch sequence that counts the number of files to be processed, see Count PDF files, to detect the end of the job.

ACTION 1:  Count PDF Files Sequence Code

/* Count PDF files */

if ( typeof global.FileCnt == "undefined" ) global.FileCnt = 0;

global.FileCnt++

ACTION 2 : Begin and End job code for batch process

// Begin job

if ( typeof global.counter == "undefined" ) {

     console.println("Begin Job Code");

     global.counter = 0;

     // insert beginJob code here

     ................

}

// Main code to process each of the selected files

try {

     global.counter++

     console.println("Processing File #" + global.counter);

     // insert batch code here.

     ...............

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

}

I got the above code when I searching.  In that they have said need to call Count PDF Files action before call Begin and End job Action.  But I don't how to call.  Can anyone help to how to merge these two sequences??

- Sudha K

TOPICS
Acrobat SDK and JavaScript

Views

734

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 31, 2017 0
Jul 31, 2017

Copy link to clipboard

Copied

Put both sequences in one sequence.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2017 0
Jul 31, 2017

Copy link to clipboard

Copied

Hi,

     I need to call the 2nd one after completing of the first one. Because the first one returns the no.of files.  Based on that the 2nd will run.

    Is there is any command to execute sequence one after another in Acrobat Javascript??

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2017 0
Jul 31, 2017

Copy link to clipboard

Copied

Not possible.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2017 0
Aug 02, 2017

Copy link to clipboard

Copied

Ok... In Javascript its not possible, can we call within application using Batch Process or anyother way??

1. If we need to get the file count of the chosen folder how can we get??

2. How can I know the starting and end of the process when running multiple files?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2017 0
Aug 02, 2017

Copy link to clipboard

Copied

1. Run Action 1

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2017 0
Aug 02, 2017

Copy link to clipboard

Copied

Hi,

    Sorry...  I think that I did give clear statement....

    1.  If I run the Action 1, it will print the file count from 1 to n.  But how can we get the no. of file.

     Screen shot 2017-08-02 at 1.50.15 PM.png

     Screen shot 2017-08-02 at 1.51.55 PM.png

     2. How can we call continuously two sequence from acrobat batch process sequence dialog?

     3. As I mentioned earlier, in Beginning and ending a batch job actions, how they used "global.FileCnt" for the value.

      Without merging 2 actions or calling action 1 and 2 continuously how that code is possible??

          Screen shot 2017-08-02 at 2.05.20 PM.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2017 0
Aug 02, 2017

Copy link to clipboard

Copied

1. You use the value of global.fileCnt ...

2. That's not possible.

3. They are using two Actions. The first one counts the files and the second one performs the desired actions on them.

You can clearly see in the comments of the code you posted that it says "Run Gather Bookmarks to Array first.".

The second Action relies on the results of the first Action, to know how many files there are to process. There's no other way of doing it, not if you're using Acrobat, at any rate.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2017 0
Aug 02, 2017

Copy link to clipboard

Copied

https://forums.adobe.com/people/Sudha+K  wrote

...

      Without merging 2 actions or calling action 1 and 2 continuously how that code is possible??

Possible with a plugin for Acrobat.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2017 0
Aug 02, 2017

Copy link to clipboard

Copied

I may be wrong, but I think it's also necessary to quit and restart Acrobat after each pair of actions, or the count will include the files from the previous runs.

Sukha K, running two actions does not sound a big deal. Perhaps it is for you. If you can tell us why, we may have a suggestion for solving that particular issue.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2017 0
Aug 02, 2017

Copy link to clipboard

Copied

No, that's not necessary. At the end of the second action you can run a simple script (via the Console or a menu item) to delete the global variables, and then you can restart the whole process from zero without having to restart the application.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2017 0
Aug 02, 2017

Copy link to clipboard

Copied

Hi,

     Yes we can delete global variable and reset the variable.  If the variable is undefined, we are assigning value to the variable (ie., Start process). How can we come to know it is end of the process?? when the process is for batch??

    Actually I want to get the details of pdf files for all files in the chosen folder (ie., batch).  I need a report of those details at the end of the process. so that I am trying this.

     I can get those details but it is batch sequence so its returning for each document. I could not find the end process (ie., end file ). If I run the sequence continuously its returning both 1st n 2nd time chosen file details.  I need to reset the values at the end of the process. So that i need to get the file count of the chosen folder and then reset.

     If I use that file count sequence in same action how can I get file count?? The file count and info getting sequence both will run for the same file know. then how can I get the file count of the chosen folder before process the each file to check whether its end of the file or not?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 02, 2017 0
Aug 03, 2017

Copy link to clipboard

Copied

Again, you can't know when the process is finished from inside the batch sequence itself. That's why you need to run it once just to count the number of files, and then another time to perform the actual processing. At that point you do know when it is going to finish, because you know how many files there are. This was explained to you several times already in this thread...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 03, 2017 0
Aug 07, 2017

Copy link to clipboard

Copied

That means manually run from the sequence panel one after another is it??

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 07, 2017 0
Aug 07, 2017

Copy link to clipboard

Copied

Yes, that's what we've been saying since the start. I think we're now on the same page.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 07, 2017 0
Sudha_K LATEST
Aug 07, 2017

Copy link to clipboard

Copied

Ok thank you...

I thought that we can call from sequence using code. So I was in that thought how call. Sorry...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 07, 2017 1