Skip to main content
Kofax

Display an Alternative Image in the Document Viewer

17773

QAID # 17773 Published

Question / Problem:

Display an Alternative Image in the Document Viewer

Answer / Solution:

How to Display an Alternative Image in the Validation Document Viewer

Download

A project demonstrating this behaviour can be found here: Example Project (created using KTM 3.5). To test the behaviour:

  1. Update the script for class "NewClass1" to correctly point to the "additional images" subfolder.
  2. Select Doc1.xdc and press F8 to test Validation.
  3. Click the buttons to switch between images A and B.

Case

Sometimes it is desirable to display an alternative image in the Document Viewer. This might be the case if, for example, you have access to an original scanned image before image cleanup was performed, and a Validation user could switch to this image to read details which might have been accidentally erased during cleanup.

A user should be able to control this process and switch between the original and "alternative" images at will.

Solution

  1. Add buttons to switch between images on the Validation form.
  2. Add script code to those buttons which switches the displayed image.

177732018-09-04_1712.png

Private Sub ValidationForm_ButtonClicked(ByVal ButtonName As String, _
ByRef pXDoc As CASCADELib.CscXDocument)
    Select Case ButtonName
        Case "SwitchToImageA"
            DisplayImage pXDoc, _
                "D:\Projects\Validation, change displayed image\additional images\A.tif"
        Case "SwitchToImageB"
            DisplayImage pXDoc, _
                "D:\Projects\Validation, change displayed image\additional images\B.tif"
    End Select
End Sub

Sub DisplayImage(pXDoc As CASCADELib.CscXDocument, sImage As String)
    Dim FSO As Object
    Dim sCurrentImage As String, oImage As CscImage
    Dim lField As Long
    
    Set FSO = CreateObject("Scripting.FileSystemObject")

    'Replace current image on disk with the new image.
    sCurrentImage = pXDoc.CDoc.Pages(0).GetImage.FileName
    FSO.CopyFile sImage, sCurrentImage, True
    Set oImage = New CscImage
    oImage.Load sCurrentImage
    pXDoc.CDoc.Pages(0).SetImage oImage
    'Refresh doc viewer, ensuring that field data is preserved.
    For lField = 0 To pXDoc.Fields.Count - 1
        pXDoc.Fields(lField).Preserve = True
    Next
    pXDoc.Reclassify pXDoc.ExtractionClass
End Sub

Applies to:

Product Version Category
AXPRO 4.0 Project Builder
  • Was this article helpful?