Running AutoExtract Jobs from a Command-Line BAT File
- Introduction
- It is possible to execute a data extraction job from outside of Adobe Acrobat via a command-line BAT file. Use this method to automate data extraction by starting the processing from an another application or Windows Task Scheduler. You would need to configure the data extraction job using a regular method (via a user interface) prior to running it via a BAT file. This functionality is available in version 1.4 and up.
- Configure AutoExtract Job
- Open a PDF form file and use Plug-ins > Extract Data > Extract Data Records From Document...” menu to configure a data extraction project. See other tutorials for details.
- Save Project Settings
- Save project settings as *.zones file by clicking “Save Settings...” button located on the main AutoExtract screen. The settings file stores all parameters required for the job such as data fields descriptions, and processing options.
- Create BAT File
- Use any plain text editor (such as Notepad) to create a blank text file. Add the following lines to the file. Make sure to replace paths and filenames with the actual filenames you are using.
-
SET AUTOEXTRACT_INPUT_FILE=C:\Data\AutoExtractTest.pdf
SET AUTOEXTRACT_CONFIG_FILE=C:\Data\Output\AutoExtractTest.zones
SET AUTOEXTRACT_LOG_FILE=C:\Data\Output\AutoExtractLog.txt
SET AUTOEXTRACT_BAT_ENABLE=ON
SET AUTOEXTRACT_MODE=Extract
"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /n /h
- Save BAT File
- Save the BAT file with *.bat file extension. Make sure to select a proper file filter in the "Save As" dialog in Notepad to avoid saving the file with a default *.txt file extension.
- Output data file and processing report will be saved into the folder as specified in the input project file (set by AUTOEXTRACT_CONFIG_FILE variable).
- Specifying Input Files
- The environment variable AUTOEXTRACT_INPUT_FILE is used to specify a full file path to the PDF file that needs to be used for the job while AUTOEXTRACT_CONFIG_FILE specifies a full file path to the settings file. Use AUTOEXTRACT_INPUT_FOLDER to specify an input folder. All PDF files from this folder will be processed.
- Saving Log File
- Add the following line to the BAT file to generate a processing log file (in plain text format). The log files are indispensable for the troubleshooting problems that often arise during the processing. You can view log file with any text editor.
-
SET AUTOEXTRACT_LOG_FILE=C:\Data\Log.txt
- Run BAT File
- The data extraction job can be executed by double-clicking on the BAT file in Windows File Explorer window or by running it from another application.
- Please note that the BAT file will open Adobe Acrobat and may display a progress bar during the processing. Use /h switch on the Acrobat's command line to optionally run Adobe Acrobat minimized:
- Starting AutoExtract from a C# Application
- Here is a sample C# code that shows how to launch AutoExtract from a .NET application and pass all necessary parameters via the environmental variables.
-
System.Diagnostics.Process firstProc = new System.Diagnostics.Process();
firstProc.StartInfo.FileName = @"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe";
firstProc.EnableRaisingEvents = true;
firstProc.StartInfo.UseShellExecute = false;
firstProc.StartInfo.Arguments = @"/n /h"; // pass command-line parameters
firstProc.StartInfo.EnvironmentVariables.Add("AUTOEXTRACT_INPUT_FILE", @"C:\Data\Test.pdf");
firstProc.StartInfo.EnvironmentVariables.Add("AUTOEXTRACT_CONFIG_FILE", @"C:\Data\Settings.zones");
firstProc.StartInfo.EnvironmentVariables.Add("AUTOEXTRACT_BAT_ENABLE", @"ON");
firstProc.StartInfo.EnvironmentVariables.Add("AUTOEXTRACT_MODE", @"Extract");
firstProc.Start();