This project has moved and is read-only. For the latest updates, please go here.

Set diferent scan area

Jun 11, 2013 at 10:13 AM
Hello,

I'd like scanning diferent letters A5, vcard, etc.
Can you help me?
Jun 12, 2013 at 5:03 PM
Hello gallz,

You can try use follow code:
    try {
        var _supportedSizesCap=this._twain32.IsCapSupported(TwCap.SupportedSizes);

        #region Get list supported sizes (as sample)

        if((_supportedSizesCap&TwQC.Get)!=0) {
            var _supportedSizes=this._twain32.GetCap(TwCap.SupportedSizes) as Twain32.Enumeration;
            var _currentSize=(TwSS)_supportedSizes[_supportedSizes.CurrentIndex];
            for(int i=0; i<_supportedSizes.Count; i++) {
                System.Diagnostics.Debug.WriteLine((TwSS)_supportedSizes[i]); //show supported sizes
            }
        }

        #endregion

        if((_supportedSizesCap&TwQC.Set)!=0) {
            this._twain32.SetCap(TwCap.SupportedSizes,(ushort)TwSS.A5);
        }
        this._twain32.Acquire();
    } catch(TwainException ex) {
        MessageBox.Show(ex.Message,"SAMPLE2",MessageBoxButtons.OK,MessageBoxIcon.Error);
    }

    public enum TwSS:ushort {
        None=0,
        A4Letter=1,
        B5Letter=2,
        USLetter=3,
        USLegal=4,
        /* Added 1.5 */
        A5=5,
        B4=6,
        B6=7,
        /* Added 1.7 */
        USLedger=9,
        USExecutive=10,
        A3=11,
        B3=12,
        A6=13,
        C4=14,
        C5=15,
        C6=16,
        /* Added 1.8 */
        _4A0=17,
        _2A0=18,
        A0=19,
        A1=20,
        A2=21,
        A4=A4Letter,
        A7=22,
        A8=23,
        A9=24,
        A10=25,
        ISOB0=26,
        ISOB1=27,
        ISOB2=28,
        ISOB3=B3,
        ISOB4=B4,
        ISOB5=29,
        ISOB6=B6,
        ISOB7=30,
        ISOB8=31,
        ISOB9=32,
        ISOB10=33,
        JISB0=34,
        JISB1=35,
        JISB2=36,
        JISB3=37,
        JISB4=38,
        JISB5=B5Letter,
        JISB6=39,
        JISB7=40,
        JISB8=41,
        JISB9=42,
        JISB10=43,
        C0=44,
        C1=45,
        C2=46,
        C3=47,
        C7=48,
        C8=49,
        C9=50,
        C10=51,
        USStatement=52,
        BusinessCard=53
    }
Jun 14, 2013 at 8:13 PM
In version 1.0.2.284 different scan area possible make use follow code:
    try {
        this._twain32.ImageLayout=new RectangleF(2,2,2,2);
        this._twain32.Acquire();
    } catch(TwainException ex) {
        MessageBox.Show(ex.Message,"SAMPLE2",MessageBoxButtons.OK,MessageBoxIcon.Error);
    }
Jun 17, 2013 at 12:51 PM
Thanks, i try more source codes, but this is work very nice.

In the dll source code not included yet?
Jun 17, 2013 at 9:50 PM
Already included.
Apr 2, 2014 at 10:32 AM
why i use the follow code its show me the error messagebox! "Источник данных не открыт."

public TwQC IsCapSupported(TwCap capability) {
        if((this._TwainState&TwainStateFlag.DSOpen)!=0) {     <<< can't pass through
            using(TwCapability _cap=new TwCapability(capability)) {
                TwRC _rc=this._DsCap(this._appid,this._srcds,TwDG.Control,TwDAT.Capability,TwMSG.QuerySupport,_cap);
                if(_rc==TwRC.Success) {
                    return (TwQC)((_TwOneValue)_cap.GetValue()).Item;
                } else {
                    return 0;
                }
            }
        } else {
            throw new TwainException("Источник данных не открыт.");
        }
    }
this is the dll source code i can't pass through " this._TwainState&TwainStateFlag.DSOpen)!=0 ".
i did open DSM. but still occur the error.. this._twain.OpenDSM();
Apr 2, 2014 at 8:38 PM
Hello, piaking.
To work with the capabilities you must first open DSM, and then open the DS. See TWAIN Specification and Saraff.Twain.Sample2.
Marked as answer by SARAFF on 6/23/2014 at 12:33 PM