Search code examples
c#scanningtwainepsontwaindotnet

Duplex Scanning Failure Using Twain API for Epson DS-510


I want to scan a document using Twain Library for Epson DS-510 scanner using C# application, but it only scans one side. The scanner supports both side scanning of a page, and it's tested using the scanner scan feature, but it doesn't do scan with the application.

Also, I have another scanner which is Canon-2510C TWAIN but it does scan both side successfully .

Lately, I have installed TWAIN Sample App to see the Twain Configuration to connect to datasource. Pictures as added an attachment below.

CAP_DublexEnabled is false as default. When I want to set CAP_DublexEnabled to TRUE, it does but when it's still same after closing the sample app and reopen again.

Does it really support both side scanning with Twain or do i have to change the code for Acquire method for TwainLib class?

Acquire Method of TwainLib class:

public void Acquire()
    {
        TwRC rc;
        CloseSrc();
        if (appid.Id == IntPtr.Zero)
        {
            Init(hwnd);
            if (appid.Id == IntPtr.Zero)
                return;
        }
        rc = DSMident(appid, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.OpenDS, srcds);
        if (rc != TwRC.Success)
            return;

        TwCapability cap = new TwCapability(TwCap.XferCount, 50);
        //TwCapability cap = new TwCapability(TwCap.DuplexEnabled, 50);
        rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap);
        if (rc != TwRC.Success)
        {
            CloseSrc();

            return;
        }

        TwUserInterface guif = new TwUserInterface();
        guif.ShowUI = 0;
        guif.ModalUI = 1;
        guif.ParentHand = hwnd;
        rc = DSuserif(appid, srcds, TwDG.Control, TwDAT.UserInterface, TwMSG.EnableDS, guif);
        if (rc != TwRC.Success)
        {

            //TwainGui.PicForm.arsivOK = false;

            CloseSrc();
            return;
        }
    }

Picture01

Picture02


Solution

  • After a copule of days with fighting, testing and seaching on the net, finally found the solution out.

    First of all, i set DuplexEnabled capability to true using the code below:

    TwCapability capDuplex = new TwCapability(TwCap.DuplexEnabled, true);
    rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, capDuplex);
    

    Afterwards, TW_RC value comes SUCCESS which means setting value is succeeded. Then we can scan both side without problem.

    But the point of view here is the type of capability, after we had set as above, you have to design TwCapability class methods according to your needs and you have to use Twain type which is bool in those methods, too.

    have a nice day all guys!