Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

Scanning without twain dialog

Last post 26 Jun 2008, 9:04 PM by Glenn. 3 replies.
Sort Posts: Previous Next
  •  26 Jun 2008, 9:35 AM 14530

    Scanning without twain dialog

    Hello,

    I am trying to scan a document without using the twain dialog box but cannot get it to work. I can scan just fine when the dialog is enabled but when if I call acquire without showing the dialog, the app just pauses for a second and then continues on, it never pulls any pages into the scanner and does not fire the Image Acquired event. There is no exception thrown, it just continues as if the scanning is complete. I have tried setting autoscan and feeder enabled to true but nothing has made a difference. Am I missing something? The code is below. Thanks for the help.

    Acquisition acquisition = new Acquisition();
    Device device = null;
    try
    {
    path =
    "c:\\atalasoftscans";
    scanCount = 0;
    if (!acquisition.SystemHasTwain || acquisition.Devices.Count == 0)
    {
    Console.WriteLine("no twain driver found");
    return;
    }
    acquisition.ImageAcquired += new ImageAcquiredEventHandler(_acquisition_ImageAcquired);
    device = acquisition.Devices.Default;
    device.HideInterface = true;
    device.Acquire();
    }
    catch (Exception ex)
    {
    Console.WriteLine(ex.Message);
    }
    finally
    {
    if (device != null)
    device.Close();
    acquisition.Dispose();
    }

  •  26 Jun 2008, 12:33 PM 14532 in reply to 14530

    Re: Scanning without twain dialog

    With the code you have, you need to set ModalAcquire to true before calling Acquire.  Otherwise it will return from the Acquire method before it has finished scanning.


    Glenn Chittenden Jr.
    Atalasoft Development Team
  •  26 Jun 2008, 1:21 PM 14533 in reply to 14532

    Re: Scanning without twain dialog

    Ok, thanks. It is working now. An additional question I have is the auto rotate setting. Is this supposed to rotate the scanned image based on the orientation of the text (e.g. if the page is upside down it will fix it) or is it just for rotating between horizontal and vertically scanned pages? I was hoping it would detect when a page was scanned upside down and fix it but it does not seem to.
  •  26 Jun 2008, 9:04 PM 14536 in reply to 14533

    Re: Scanning without twain dialog

    Here is how the TWAIN spec describes this feature:

    "When TRUE this capability depends on intelligent features within the Source to automatically rotate the image to the correct position.

    There are no criteria for how this automatic rotation is determined. A Source may use a field of text, or some distinguishing non-text field, such as a barcode or a logo, or it may rely on form recognition to help rotate the document."

    If the driver doesn't support this, then setting it will not do anything.  You can use the QueryCapability method to find out if the driver supports it.  Or use GetSupportedCapabilities for a full list of features the driver supports.
     


    Glenn Chittenden Jr.
    Atalasoft Development Team
View as RSS news feed in XML