dynarithmic / twain_library

Dynarithmic TWAIN Library, Version 5.x
Apache License 2.0
56 stars 24 forks source link

How to set up Paper ejection direction? #49

Open CapacitorDev opened 1 year ago

CapacitorDev commented 1 year ago

Hi, my scan has two ejection forward and backward.

any one know how to set up it by using code C#?

thank you!

dynarithmic commented 1 year ago

I am not sure I know what "paper ejection" means, but it does not sound like a standard TWAIN capability.

1) What is the name of the device?

2) If it is a custom TWAIN capabilty, you will need to know which one it is and set it using DTWAIN_SetCapValues. For this, it requires that you know from the manufacturer if custom capabilties are supported, and which one it is.

CapacitorDev commented 1 year ago

hi @dynarithmic , thank you for the reply.

"paper ejection" --> when you open with UI, you will see this setting. paper_ejection

I want the code let the paper forward out of the scanner after scanning. ( not return backward the paper, it occurs Paper Jam a lot this way )

  1. What is the name of the device? --> plustek MobiOffice D600 Plus
  2. Seems like it's not a standard TWAIN CAP. I will do more research about this DTWAIN_SetCapValues
dynarithmic commented 1 year ago

If you run the DTWDEMO.exe program that is in the demo .zip file, you can select the source, and get a listing of the capabilities if you choose Source Properties... from the main menu Source Selection Test.

If you see capabilities named CAP_CUSTOMBASE + xxxx, those are the custom capabilities.

CapacitorDev commented 1 year ago

I found 6 custombase but I can not retrieve the value of them using DTWAIN_GetCapValues

  1. CAP_CUSTOMBASE + 100 re:32868 0x8064
  2. CAP_CUSTOMBASE + 110 re:32878 0x806E
  3. CAP_CUSTOMBASE + 111 re:32879 0x806f
  4. CAP_CUSTOMBASE + 114 re:32882 0x8072
  5. CAP_CUSTOMBASE + 115 re:32883 0x8073
  6. CAP_CUSTOMBASE + 116 re:32884 -- 0x8074

Here is the C# code, only CAP_CUSTOMBASE + 100 supported to getcapvalues. ` DTWAIN_ARRAY defa = IntPtr.Zero;

            int[] com = { 0x8064 , 0x806E , 0x806f , 0x8072, 0x8073, 0x8074 };

            for (int i = 0; i < 6; i++)
            {
                int isCapSup = TwainAPI.DTWAIN_IsCapSupported(SelectedSource, com[i]);
                Console.WriteLine("Supported?? " + com[i] + " : ---> " + isCapSup);

                int ok = TwainAPI.DTWAIN_GetCapValues(SelectedSource, com[i], TwainAPI.DTWAIN_CAPGET, ref defa);
                Console.WriteLine("Get value ok?? " + com[i] + "  -----> " + ok);
                if(ok == 1)
                {
                    long count = TwainAPI.DTWAIN_ArrayGetCount(defa);
                    double vl = 0;
                    for (int j = 0; j < count; j++)
                    {

                        TwainAPI.DTWAIN_ArrayGetAtFloat(defa, j, ref vl);
                        Console.WriteLine("Value " + vl);
                    }
                }
            }`

Supported?? 32868 : ---> 1 Get value ok?? 32868 -----> 1 Value 1.61900371485718E-319 Supported?? 32878 : ---> 1 Get value ok?? 32878 -----> 0 Supported?? 32879 : ---> 1 Get value ok?? 32879 -----> 0 Supported?? 32882 : ---> 1 Get value ok?? 32882 -----> 0 Supported?? 32883 : ---> 1 Get value ok?? 32883 -----> 0 Supported?? 32884 : ---> 1 Get value ok?? 32884 -----> 0

dynarithmic commented 1 year ago

DTWAIN does not know what those capabilities do, what data type they are (string, booleans, integers, etc.), and whether they can be set (some may be read-only).

You will need to get the custom capability information from the manufacturer (Plustek) as to the data type, container used to store the information, etc. I do not know where to get this information, probably from whoever creates the Plustek drivers.

Once you get this information, you would call DTWAIN_GetCapValuesEx() specifying the container to use and data type.

The information you get should be similar to what you will find in the Twain specification manual in Chapter 10-3. You see the capabiltiy, container used, data type, etc. This is the information you need from Plustek. All DTWAIN can do is allow you to retrieve the values, but you must know how to set up the retrieval of the values.

You could try a different data type instead of float to see if any of the ones that return "success" give any correct values.

dynarithmic commented 1 year ago

See DTWAIN_GetCapValuesEx2. This gives you detailed information on how to properly get the cap values, once you get the information about the capability.