How to Create a Script for Document Preprocessing

You can fine-tune document preprocessing using scripts that alter or improve input files.

Scripts are run separately for each file on a Processing Station that has been given the Preprocessing or Processing and Preprocessing role.

Important! For a script to work properly with shared resources on a Processing Station, you should run the Processing Station under a user account which has the necessary rights to access these resources.

To create and use a script, do the following:

  1. Click the Script... button on the 1. Input tab of the Workflow Properties dialog box.
  2. In the Script Editor dialog box that opens, select a scripting language and enter the script text. The reference "this" or "Me" refers to the InputDocument object.
  3. To check the script, click the Check button. To save the script, click OK.

For details on using scripts, see Using Scripts in ABBYY FineReader Server.

Sample

The sample script provided below is written in JScript and is intended for preprocessing input files. This script copies input files and changes the file extensions of the copies to *.pdf. If you need to convert input files, specify the corresponding utility in the code of the script. If a file is converted successfully, a success record will be added into the event log and the converted file will be processed. If conversion fails, a failure record will be added to the event log and the input file will be moved to the Exceptions folder.

var fso =new ActiveXObject("Scripting.FileSystemObject");
var inputFile = InputFileLocation;
var newFile = fso.BuildPath(fso.GetParentFolderName(inputFile), fso.GetBaseName(inputFile)+".pdf");
StartInputFileReplacement( newFile );
// Call your conversion utility here
var cmdLine ='"%COMSPEC%" /c    COPY "'+ inputFile +'" "'+ newFile +'"  2>&1 ';
var Shell =new ActiveXObject("WScript.Shell");
var oExec = Shell.Exec( cmdLine );
while (oExec.Status==0){};
if(oExec.ExitCode==0){
   if(fso.FileExists(newFile)){
      CompleteInputFileReplacement();
      return;
   }
}
LogMessage("Conversion failed, error code is "+ oExec.ExitCode);

Note. If the document is not processed within the script's timeout period, an error will occur and the job will be discarded.

See also

Using Scripts in ABBYY FineReader Server

26.03.2024 13:49:49

Please leave your feedback about this article

Usage of Cookies. In order to optimize the website functionality and improve your online experience ABBYY uses cookies. You agree to the usage of cookies when you continue using this site. Further details can be found in our Privacy Notice.