Testing for paper jams
Testing for paper jams
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
Thank you,
Steve
Re: Testing for paper jams
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
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
Re: Testing for paper jams
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
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
Re: Testing for paper jams
Hi,
Unfortunately, your scanner seems to doesn't provide this feature.
In your code, the TwainGetLastConditionCode() should be placed after:
With best regards,
Loïc
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
Who is online
Users browsing this forum: No registered users and 1 guest