3.6.2.8. Export Zone Bitmap from a Capture Grid Control After Export with VBScript
While exporting data and documents we can export form data and line item data from Capture Grid objects.
If one of the cell is defined as Mark Detection, it is possible to extract the image of this cell.
In this sample we want to know if a cell is signed and export true or false whenever it is signed or not. We can also name the images using one of the fields as the file name.
It is very important to turn on Advanced OCR Reading for the columns that will be exported.
Any OCR Engine can be used but PDF-Text is recommended as no further processing will be done. Also make sure Adjust is turned off so the entire area is exported correctly.
Zone bitmap to save
|
|
Data to compose export file name
|
|
For this, we'll use the Batch functions GetXgridFieldValue and GetXgridFieldBitmap. To edit this script we have to activate OnExportFinish VBScript
We've configured an export module to generate a xml file.
The name of the resulting .bmp file will need to be composed like this:
path to the xml generated+field "Barcode 1" from document+field "ID" from capture grid+".bmp"
We navigate all documents and navigate each grid to extract data as .bmp
Function GetPath(file)
Dim objFSO, objFile, objFolder
Dim intIndex
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(file)
Set objFolder = objFile.ParentFolder
GetPath=objFolder.Path
End Function
Set Batch = ChronoApp.GetCurrentBatch
Dim NumDocs
NumDocs=Batch.GetDocCount
'navigating records
For numDoc = 0 To NumDocs-1
If (Batch.IsValidated(numDoc)) Then
'we need the path of a file generated by xml export module
'when the document has exported, the system field "expinfo.XML Report.File Sysstem_1" is filled with the generated xml
'we can use it to extract the path to save the bmp in the same directory
Dim strPath
strPath = Batch.GetSystemField (numDoc, "expinfo.XML Report.File System_1")'first part of a result bmp
strPath=GetPath(strPath)'we need Only file path
Dim Barcode1
Barcode1 = Batch.GetUserField( numDoc, "Barcode 1")'Second part of a result bmp
'MsgBox "Document Barcode1: "+Barcode1
Dim tableNumber, numRows
tableNumber=1'we are using table 1
numRows=Batch.GetXgridRowCount (numDoc,tableNumber)
MsgBox "Total Records in xgrid table: " + CStr(numRows)
'navigating xgrid table records
Dim row
For row = 0 To numRows-1
'Extract field "ID" from xgrid For compose export bmp file
Dim strIndexValue
strIndexValue=Batch.GetXgridFieldValue (numDoc,tableNumber, row, "Index")'Third part of a result bmp
Dim strSaveFile
strSaveFile=strPath+"\"+Barcode1+"_"+strIndexValue+".bmp"
'MsgBox "File to save: "+strSaveFile
If Batch.GetXgridFieldBitmap (numDoc,tableNumber, row, "Signature", strSaveFile) Then
Else
MsgBox "An Error occurred saving file: " +strSaveFile
Exit For
End If
Next
End If
Next