0

We have two source of inputs to create a Batch first is Folder Import and second is Email import.

I need to add condition where if the source of image is Email it should not allow to rotate the image and like wise if source if Folder import it should rotate the image.

I have added a script for this in KTM. It is showing proper message of the source of image but it is not stopping the rotation of the image.

Below check the below script for reference.

Public Function setRotationRule(ByVal pXDoc As CASCADELib.CscXDocument) As String
   Dim i As Integer
   Dim FullPath As String
   Dim PathArry() As String

    Dim xfolder As CscXFolder

    Set xfolder = pXDoc.ParentFolder

    While Not xfolder.IsRootFolder
        Set xfolder = xfolder.ParentFolder
    Wend
    'Added for KTM script testing
    FullPath= "F:\Emailmport\dilipnikam@gmail.com_09-01-2014_10-02-37\dfdsg.pdf"'

    If xfolder.XValues.ItemExists("AC_FIELD_OriginalFileName") Then
        FullPath= xfolder.XValues.ItemByName("AC_FIELD_OriginalFileName").Value
    End If

    PathArry() = Split(FullPath,"\")
    MsgBox(PathArry(1))

    If Not PathArry(1) = "EmailImport" Then
        For i = 0 To pXDoc.CDoc.Pages.Count - 1
            pXDoc.CDoc.Pages(i).Rotation = Csc_RT_NoRotation
        Next i
    End If

End Function
MC ND
  • 69,615
  • 8
  • 84
  • 126
Manish Sharma
  • 61
  • 1
  • 2
  • 9
  • Not `vbscript`, but this `Not PathArry(1) = "EmailImport"` results always to `true` because of keying mistake in `FullPath= "F:\Emailmport\dilipnikam...` – JosefZ Sep 26 '14 at 15:34
  • Did you confirm that it wasn't due to the typo mentioned above? From what event are you calling this function? – Stephen Klancher Oct 01 '14 at 03:20

1 Answers1

0

The KTM Scripting Help has a misleading topic named "Dynamically Suppress Orientation Detection for Full Page OCR" where it shows setting Csc_RT_NoRotation from the Document_AfterClassifyXDoc event.

The reason I think this is misleading is because rotation may already have occurred before that event and thus setting the property has no effect. This can happen if layout classification has run, or if OCR has run (which can be triggered by content classification, or if any project-level locators need OCR). The sample in that topic does suggest that it is only for use when classifiers are not used, but it could be explained better.

The code you've shown would be best called from the event Document_BeforeProcessXDoc. This will run before the entire classify phase (including project-level locators), ensuring that rotation could not have already occurred.

Of course, also make sure this isn't because of a typo or anything else preventing the code from actually executing, as mentioned in the comments.

Stephen Klancher
  • 1,374
  • 15
  • 24
  • Hi Stephen i am not sure this could be the exact cause for No Rotation because as suggested by Kofax "Csc_RT_NoRotation" from the Document_AfterClassifyXDoc event i have called event in Document_BeforeClassifyXDoc it was working fine but i am unable to add a conditional Rotation to it based on Scanned and Eamil Invoice Source to it. Will try in Document_BeforeProcessXDoc event also. Thanks for your Suggestion Please keep Posting. – Manish Sharma Oct 07 '14 at 04:03
  • Did you fix the typo that was mentioned in previous comments? "Emailmport" =/= "EmailImport" – Stephen Klancher Oct 07 '14 at 04:43
  • Separately, is OriginalFileName a field that is mapped to a root folder field in then synch tool, or just an unmapped Kofax Capture field that you want to use from script? If the later, make sure you checked the option mentioned in this answer: http://stackoverflow.com/a/25951923/221018 Consider also that as your code is currently written, if the XValue exists, it will replace your test value even if it is blank. – Stephen Klancher Oct 07 '14 at 04:55
  • OriginalFilename field is mapped to Sync Tool. I have also fixed the typo that is mentioned for Emailimport – Manish Sharma Oct 07 '14 at 06:08