Type 3: PowerShell during processing
The subfolder templates may not cover complex folder structures. For these cases, BarcodeOCR calls a PowerShell script during processing, but before saving. The script receives all information about the processing, can evaluate it without restrictions and returns the subfolder path and the file name to BarcodeOCR. BarcodeOCR then uses these values when it saves the file.
You set up the interface in the Naming and sorting step of the configuration, with the option Use an external script to define the name of the Subfolder.
PowerShell scripts must be signed before use, or you first need to adjust the execution policy. If execution is not allowed, an entry appears in the error log and BarcodeOCR does not save the output files in the path you defined. See Prepare PowerShell.
For use cases, such as sorting by recognized text or by a certain text in the barcode, see Use an external script to define the name of the subfolder.
General
- BarcodeOCR runs the interface while it prepares saving an output file.
- The parameters are passed as a data object.
- BarcodeOCR waits until the script has finished and evaluates the returned values. If the values are not empty, BarcodeOCR uses them for saving.
- Renaming and duplicate handling defined in the user interface are applied anyway.
- There is no timeout while waiting for the script.
Parameters
The interface passes a data object. It can also contain arrays and long texts.
General parameters
| Parameter | Description | Sample values |
|---|---|---|
ConfigurationName | Name of the configuration | "Test" |
ConfigurationGuid | Unique identifier of the configuration | cbfc4771-7f73-481e-b1ca-e4b95eb3d605 |
ConfigurationFilePath | File path to the configuration file | "C:\ProgramData\Keil IT\BarcodeOCR\AnalyserConfig.xml" |
UsedBarcode | Recognized barcode used for splitting and renaming | Content of the barcode, empty for error files |
Result | Was the file saved in the output folder? | True = file saved in the output folder, False = file saved in the error folder |
ErrorReason | Reason why the document was placed in the error folder | NoBarcode, CorruptedFile, Unknown, Duplicate, NameError |
FileProcessStartTime | Time when processing of the file started | – |
SourceFilePath | Full path to the input file | C:\Config\dec24748\Tour\Sample.pdf |
BackupFilePath | Full path to the file in the backup folder (if active) | C:\Config\dec24748\Tour\Backup\Sample_eb3d605.pdf |
DestinationFilePath | Full path to the output file | C:\Config\dec24748\Tour\Error\No_Barcode_1.pdf |
Subfolder | Subfolder structure, if defined beforehand | Subfolder\Sub-Subfolder |
NumberOfPages | Number of pages in the document | 4 |
NumberOfRemovedPages | Number of pages removed by blank page detection | 0 |
StartPage | Page number of the first page in the original batch | 1 |
EndPage | Page number of the last page in the original batch | 4 |
Parameters per page
The following information is passed as an array, with one entry per page of the output document.
| Parameter | Description | Sample values |
|---|---|---|
Number | Page number | 4 |
RecognizedText | Recognized text on this page (if text recognition is enabled) | "Lorem ipsum ...." |
Barcodes | List of recognized barcodes on this page | Per barcode: type, text and X/Y coordinates |
Return values
- The interface can return two values to BarcodeOCR, which BarcodeOCR takes into account in further processing.
- The sample script simplifies this step. It offers two corresponding variables that you only need to set.
- If the script returns empty variables, the values are not overwritten.
- BarcodeOCR logs the values returned by the script in the process log.
- If the script throws an error, BarcodeOCR ignores the output of the script and processes the file according to the settings of the configuration.
| Return value | Description | Sample values |
|---|---|---|
SUBFOLDER_NAME | Path of the subfolder structure to be used. BarcodeOCR creates missing folders. | Invoices, Invoices/CustomerName/BranchB |
FILE_NAME | File name to be used for the output file. The script can overwrite it. | Invoice_VariableFromSQL_Test.pdf |