Loading...

Testing for paper jams

Support for GdTwain ActiveX and GdTwain Pro ActiveX/SDK.

Testing for paper jams

Postby steve888 » Mon Nov 23, 2009 4:49 pm

I would like to know if there is a way to test in my code for a paper jam during a scanning process. While testing my application a paper document got jammed in the scanner, yet the code continued to run and gave the usual successful scan message box.

Thank you,
Steve
steve888
 
Posts: 7
Joined: Wed Oct 14, 2009 9:42 pm

Re: Testing for paper jams

Postby Loïc » Mon Nov 23, 2009 5:36 pm

Hi Steve,

You can try to use the TwainGetLastConditionCode() just after a scan process to get information about the state. If the returned value is 20 (Paper jam) you got a paper jam.
However, some scanner doesn't provide such information, it depends of the TWAIN driver.

Hope this helps.

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4441
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Testing for paper jams

Postby steve888 » Wed Nov 25, 2009 8:26 pm

Hi Loïc,

I tried it in several places in my code but I can't seem to catch the error when a paper jams. My printer/scanner is the HP LaserJet M1319f MFP.

Here is a section of code where scanning is being performed. Is there a particular line in my code where this might work best? I appreciate your efforts.

Steve

Code: Select all
    DoCmd.Hourglass (True)
                       
    If cntTwain.TwainOpenDefaultSource() Then
        cntTwain.TwainSetAutoFeed (True)
        cntTwain.TwainSetAutoScan (True)
        cntTwain.TwainSetHideUI (True)
        cntTwain.TwainSetCurrentResolution (300) 'Scan in 300 DPI
        cntTwain.TwainSetCurrentPixelType (TWPT_BW) 'Black & White scanning
        cntTwain.TwainSetCurrentBitDepth (1) ' 1 bpp scanning
               
        If cntTwain.TwainPdfOCRStartEx(strDocName) = 0 Then
       
            While cntTwain.TwainAcquireToGdPictureImage(Screen.ActiveForm.Hwnd) <> 0
                lRotation = cntTwain.OCRTesseractGetOrientationEx(TesseractDictionaryEnglish, strDictionary, 3)
                If lRotation <> RotateNoneFlipNone Then
                    'This rotates the document, if necessary, for OCR
                    Select Case lRotation
                        Case Rotate90FlipNone
                            cntTwain.Rotate Rotate270FlipNone
                        Case Rotate180FlipNone
                            cntTwain.Rotate Rotate180FlipNone
                        Case Rotate270FlipNone
                            cntTwain.Rotate Rotate90FlipNone
                    End Select
                End If
                Call cntTwain.TwainAddGdPictureImageToPdfOCR(cntTwain.GetNativeImage, TesseractDictionaryEnglish, strDictionary)
                cntTwain.CloseNativeImage
            Wend
            cntTwain.TwainPdfOCRStop
       
        End If
        cntTwain.TwainCloseSource
       
        DoCmd.Hourglass (False)
                       
        MsgBox "Document scanning and OCR completed successfully.", vbInformation, "Scan"
               
        cntTwain.TwainUnloadSourceManager
    Else
       MsgBox "Can't open default source, Twain state is: " & Trim(Str(cntTwain.TwainGetState))
    End If
steve888
 
Posts: 7
Joined: Wed Oct 14, 2009 9:42 pm

Re: Testing for paper jams

Postby Loïc » Thu Nov 26, 2009 9:25 am

Hi,

Unfortunately, your scanner seems to doesn't provide this feature.

In your code, the TwainGetLastConditionCode() should be placed after:
Code: Select all
Wend



With best regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4441
Joined: Tue Oct 17, 2006 10:48 pm
Location: France


Return to GdTwain [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest

cron