TWAIN scanning enhancement: New optional parameters added to AUI_IMAGE opcode 7 (IMGOP_ACQUIRE) to allow the application to request a set number of pages to be scanned, and to optionally hide the scanner's user interface.
xcall AUI, AUI_IMAGE, IMGOP_ACQUIRE, HANDLE, STATUS, FSPEC, COMP, {,APPNAME {,PAGES, SCANFLAGS}}
Where:
pages (Num) [in/out]
specifies the desired (or maximum) number of pages to scan. On return, it will contain the actual number scanned.
scanflags (Num) [in]
specifies flags (defined in ashell.def) affecting the scanning operation:
Symbol |
Value |
Meaning |
---|---|---|
IMGSF_HIDEUI |
&h0001 |
Hide the scanner's user interface dialog, forcing the user to scan based on the settings previously established. |
IMGSF_ADFOUT |
&h0002 |
Quit when the Automatic Document Feeder (ADF) is out of paper (even if less than the number of pages requested) |
IMGSF_CONTINUE |
&h0004 |
Keep scanning until the requested # of pages is received, or the operator terminates the operation, or an unrecoverable error. This may be the same as the default operation, although in cases where there is no ADF, it may be necessary in order to force the operation to continue for multiple pages, since otherwise the scanner may return an ambiguous status, making it unclear to the application whether the operator decided not to continue, or the scanner just didn't now how to do multiple scans in one call. |
The individual pages of the scan will be saved using the filespec, but with the page # appended. So if you set filespec = "scan.tif", the resulting files would be "scan-1.tif", "scan-2.tif", etc. If you need more flexibility in the file naming, I could also allow you to embed a code within the filename to receive the page number, so that you could end up with files names "scan001inv.tif", "scan002inv.tif", etc.
Typical multipage scanning scenarios:
• | Documents with fixed # pages (say, 5). Set PAGES=5, and IMGSF_CONTINUE flag. Depending on the nature of the scanner and whether the IMGSF_HIDEUI flags is set, the user may see a dialog containing SCAN/CLOSE/CANCEL buttons. Or maybe the scanner just returns after each scan (in which case the XCALL will internally keep calling it until it gets the 5 pages or an explicit CANCEL or other error is returned). Assuming all goes well, XCALL returns STATUS=0 and PAGES=5 to the caller. If we run into an error on page 3 and can't continue, we would return PAGES=2 (2 pages scanned) and STATUS=<some error code>. |
• | Documents with variable # pages. Set PAGES to a suitably high maximum value, perhaps 999999. If you are using the feeder to determine the end of the document (i.e. the operator will load exactly one document at a time), set IMGSF_ADFOUT. Else rely on the user to terminate the scan job after the desired number of pages. (Although there is some question whether it will always be possible to distinguish between a true "cancel", which should return STATUS=15, and "done" which ideally would return STATUS=0 to the application, but necessarily will have to return some other status to the internal interface to get it to stop scanning.) The application would presumably look at STATUS to make sure that the scan operation terminated normally, and then at PAGES to see how many pages were scanned. |
There are also two new status codes:
Value |
Meaning |
---|---|
25 |
ADF out of paper |
24 |
Unsupported platform |
See the IMAGE.BP[908,32] program in the EXLIB for an example of using the new parameters.