Multi-Page Scanning with EZTwain Pro

Overview  Download  Licensing  Features  Code Wizard  Stories  User GuidePDF file

If you want to scan to a multipage file, just use TWAIN_AcquireMultipageFile! Here's a sample scan in Visual FoxPro:

    TWAIN_AcquireMultipageFile(ThisForm.hWnd, "c:\document.tif")
    IF TWAIN_LastErrorCode()<>0
        TWAIN_ReportLastError("Scan error.")
    ENDIF

Here is a very different code sequence, in C++/MFC. This code sample attempts to hide the scanner's user interface, selects duplex scanning, B&W 1-bit pixels, 100 DPI, reflective media, and to save each scanned page into a separate tempNN.BMP file, after doing some (unspecified) image processing in memory. This code sample was generated by the EZTwain Pro toolkit's Code Wizard:


    char fileName[260];
    int i;
    HANDLE hdib;
    TWAIN_SetHideUI(1);
    if (TWAIN_OpenDefaultSource()==1) {
        TWAIN_EnableDuplex(1);
        TWAIN_SetPixelType(0);
        TWAIN_SetBitDepth(1);
        TWAIN_SetResolution(100);
        TWAIN_SetLightPath(0);
        TWAIN_SetXferCount(-1);
        TWAIN_SetAutoScan(1);
        TWAIN_SetMultiTransfer(1);
        i = 1;
        do {
            wsprintf(fileName, "c:\\temp%d.bmp", i);
            hdib = TWAIN_Acquire(m_hWnd);
            if (hdib==NULL) {
                break;
            }
            // <your image processing here>
            TWAIN_WriteNativeToFilename(hdib, fileName);
            DIB_Free(hdib);
            i = i+1;
        } while (TWAIN_State()>=6);
        TWAIN_CloseSource();
    }
    if (TWAIN_LastErrorCode()) {
        TWAIN_ReportLastError("Unable to scan.");
    }