PostClassify
This event triggers after all defined classification methods are executed by the Cedar Project.
Syntax
ScriptModule_PostClassify (pWorkdoc as SCBCdrPROJLib.SCBCdrWorkdoc)
Parameter | Description |
---|---|
pWorkdoc | Classified workdoc object. |
Sample Code
Private Sub ScriptModule_PostClassify(pWorkdoc as SCBCdrPROJLib.SCBCdrWorkdoc)
Dim imgDocument as SCBCroImage
Dim lngTagCount as Long
'Imprint number is stored as a Tifftag in the image file - the following code extracts the Tifftag
'information and sets the field value.
'NOTE: this works only if there is a single Tifftag - would require modification for more!
Set imgDocument = pWorkdoc.Image(0)
lngTagCount = imgDocument.TiffTagCount
'Check that there is at least 1 tifftag.
If (lngTagCount > 0) Then
Dim intImageCount as Integer
Dim intImageCounter as Integer
intImageCount=pWorkdoc.PageCount 'Get the number of pages in TIF
Dim imgCollection() as SCBCroImage
ReDim imgCollection(intImageCount) 'Set an image collection variable to store all the pages of the image
'Store all pages of TIF image onto a temporary image collection array
For intImageCounter=0 To intImageCount-1
Set imgCollection(intImageCounter)=pWorkdoc.Image(intImageCounter)
Next
Dim strTag as String
strTag = CStr(Format(Now(), "yyyymmddhhMMss")) & "123456" 'Set the Info to place into TIF Tag
imgCollection(0).TiffTagClearAll 'Clear All TIF Tags
imgCollection(0).TiffTagAddASCII 33601, strTag 'Add the TIF Tag
imgCollection(0).SaveFile(pWorkdoc.DocFileName(0)) 'Save modified image collection with TIF Tag and overwrite existing image
'Reset the collection to the new image in workdoc
For intImageCounter=1 To intImageCount-1
imgCollection(intImageCounter).AppendToMultiImageFile(pWorkdoc.DocFileName(0))
Next
MsgBox("Tag = " & imgDocument.TiffTagString(lngTagCount)) 'Message box to show TIF Tag
Else
' If there is no Tifftag, can set the field to false - no Tifftag means that something has gone wrong with scanning. Generate a new Doc ID.
MsgBox("No Tag")
End If
End Sub
Sample Code
Private Sub ScriptModule_PostClassify(pWorkdoc as SCBCdrPROJLib.SCBCdrWorkdoc)
Dim imgDocument as SCBCroImage
Dim lngTagID as long
lngTagID = 12345
Set imgDocument = pWorkdoc.Image(0)
Call fnCreateTiffTag(imgDocument, lngTagID, "Test")
End Sub
Sample Code
The following script retrieves OMR blackness.
Private Sub ScriptModule_PostClassify(pWorkdoc As SCBCdrPROJLib.ISCBCdrWorkdoc)
Dim oWorktext As New SCBCroWorktext
Dim lCharIndex, lTagType As Long
Dim vTagValue As Variant
Dim strBlacknessValue As String
Dim oImage As SCBCroImage
Dim lImageWidth, lImageHeight As Long
Dim oPage As SCBCroPage
Dim strMessage As String
On Error Resume Next
Set oImage = pWorkdoc.Image(0)
If oPage Is Nothing Then
Project.LogScriptMessageEx CDRTypeError, CDRSeverityLogFileOnly, "Image object is Null"
End If
lImageWidth = oImage.Width
lImageHeight = oImage.Height
strMessage = "Image Width == " & lImageWidth & ", while Image Height == " & lImageHeight
If ScriptModule.ModuleName = "Designer" Then
MsgBox strMessage
Else
Project.LogScriptMessageEx(CDRTypeInfo, CDRSeveritySystemMonitoring, strMessage)
End If
Set oPage = Project.AllClasses.ItemByName("Invoices").Page
If oPage Is Nothing Then
Project.LogScriptMessageEx CDRTypeError, CDRSeverityLogFileOnly, "Page object is Null"
End If
' Enable retrieval of OMR blackness in RTS
Set oPage.Image = oImage
oPage.Zones.ItemByName("MyOmrZone").Recognize(oWorktext)
'Retrieve the blackness info for the OMR zone
oWorktext.GetTag(0, lCharIndex, lTagType, vTagValue)
strBlacknessValue = CStr(CDbl(vTagValue))
strMessage = "OMR Recognition Result == " & oWorktext.Text & Chr$(13) & "OMR Blackness == " & strBlacknessValue
If ScriptModule.ModuleName = "Designer" Then
MsgBox strMessage
Else
Project.LogScriptMessageEx(CDRTypeInfo, CDRSeveritySystemMonitoring, strMessage)
End If
End Sub