Skip to main content
Kofax

What may be the problem if a Document extracted with a Mixed Print profile errors with "Fox-Exception: Index (0) out of range (0 - -1)" or shows up in KTM Validation with the "No XDocument found for the current document; a new XDo

16089

QAID # 16089 Published

Question / Problem:

What may be the problem if a Document extracted with a Mixed Print profile errors with "Fox-Exception: Index (0) out of range (0 - -1)" or shows up in KTM Validation with the "No XDocument found for the current document, a new XDocument will be created." message?

Answer / Solution:

This may be an issue reported as SPR 96136, fixed in 5.5.2.0, which occurs on certain images when using the Mixed Print profile. A workaround for this issue is to call the following function from Document_AfterExtract in the project level script:

'Prevents a problem that can occur with Mixed Print profiles
'MUST be called from Document_AfterExtract in the project level script
Public Function Workaround_SPR96136(pXDoc As CscXDocument) As Boolean
    'return true if an error was detected and OCR was deleted on this document, otherwise false
    Workaround_SPR96136 = False

    Dim RepNum As Integer
    Dim Rep As CscXDocRepresentation
    Dim DeleteRep As Boolean
    For RepNum = pXDoc.Representations.Count - 1 To 0 Step -1
        'Check each OCR rep
        Set Rep = pXDoc.Representations.ItemByIndex(RepNum)
        DeleteRep = False
        Dim PageNum As Integer
        Dim Page As CscXDocPage
        For PageNum = 0 To Rep.Pages.Count - 1
            'Check each page
            Set Page = Rep.Pages.ItemByIndex(PageNum)

            Dim BoxNum As Integer
            Dim Box As CscXDocBox
            For BoxNum = 0 To Page.Boxes.Count - 1
                Set Box = Page.Boxes.ItemByIndex(BoxNum)

                'If the box has a index higher than is present on the document rep
                '  then this is invalid as reported in SPR 96136
                If Box.IndexOnDocument > Rep.Boxes.Count - 1 Then
                    'the only way to prevent the error when the xdc is saved is to delete the OCR
                    pXDoc.Representations.Remove(RepNum)
                    DeleteRep = True

                    'warn only in Project Builder
                    If Project.ScriptExecutionMode = CscScriptExecutionMode.CscScriptModeServerDesign Then
                        MsgBox("This document triggered an error condition reported as SPR 96136, so " & _
                            "OCR is deleted after extraction to prevent a runtime error.")
                    End If
                    'error detected, return true
                    Workaround_SPR96136 = True

                    Exit For 'Deleting the rep, stop checking boxes
                End If
            Next

            If DeleteRep = True Then
                Exit For 'Deleting the rep, stop checking pages
            End If
        Next
    Next
End Function

Applies to:

Product  Version  Category 
AXPRO 5.5 Server
AXPRO 5.5 Validation