These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Batching PDFs and Javascript

mczajka
Registered: Oct 11 2005
Posts: 29

If I run a Javascript batch sequence on a folder of files, or a bunch of files I have selected, is it possible through Javascript to tell if I'm processing the first file or last file in the set?

My Product Information:
Acrobat Pro 9.3.1, Windows
mczajka
Registered: Oct 11 2005
Posts: 29
Nevermind, found it:

http://www.adobe.com/devnet/acrobat/pdfs/batch_sequences.pdf
try67
Expert
Registered: Oct 30 2008
Posts: 2398
The answer, by the way, is that you can know when you're processing the first one, but not the last one.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
If you download the Batch Sequence examples, and run the "Count PDF Files" you will create a global variable that holds the file count for the number of files you want to process, global.FileCnt. So if one adds a local counter to one's batch processing script, one can determine if they are at the last file with a simple comparison. Not as straight forward as many batch processes, but having to run multiple batch processes to perform an entire process is not unheard of.

[url=http://www.planetpdf.com/developer/article.asp?ContentID=generating_reports_with_javasc&gid=6570]Generating Reports with JavaScript[/url] by Dave Wright creates a report of the document information, number of pages, number of form fields, file size and file name. There is an initialization process to define some global variables and objects, the selection and processing of a group of files, and finally a closing to the global report object and displaying the results.

George Kaiser

mczajka
Registered: Oct 11 2005
Posts: 29
I've discovered that working with some of these global variables, and resetting them, and such, it's important to "uncheck" the Preference under Settings called "Enable global object security policy" so you can have all batches and files reset your globals, if necessary instead of only the ones creating them.