←Select platform

AcquireEvent Event

Summary
Occurs for each page acquired from the currently selected WIA source using the Acquire or AcquireSimple methods and it will also get called for each end of page to provide the user with the EndOfPage flag through the Flags member of the WiaAcquireEventArgs event argument to indicate the end of each page transfer.

Syntax
C#
C++/CLI
Python
public event EventHandler<WiaAcquireEventArgs> AcquireEvent 
public: 
event EventHandler<WiaAcquireEventArgs^>^ AcquireEvent 
def AcquireEvent(sender,e): # sender: WiaSession e: WiaAcquireEventArgs 
Event Data

The event handler receives an argument of type WiaAcquireEventArgs containing data related to this event. The following WiaAcquireEventArgs properties provide information specific to this event.

PropertyDescription
Cancel Aborts the acquire operation.
FileName Indicates the full filename and path into which the current scanning operation is saving the page(s) that are being acquired.
Flags Indicates the start and the end of each acquired page.
Image Gets the IRasterImage which holds the image data acquired from the WIA Data Source.
Percent Indicates the percent completion of the acquisition process from the WIA source.
Remarks

If the user acquired several pages at the same time, a separate event occurs for each page.

For more information, refer to How to Acquire from the WIA Source.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Wia; 
 
 
      
public void IsAvailableExample(IntPtr parent) 
{ 
   if (!WiaSession.IsAvailable(WiaVersion.Version1)) 
   { 
      Console.WriteLine("WIA version 1.0 not installed."); 
      return; 
   } 
 
   WiaSession wiaSession = new WiaSession(); 
   wiaSession.Startup(WiaVersion.Version1); 
 
   DialogResult res = wiaSession.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault); 
   if (res != DialogResult.OK) 
   { 
      Console.WriteLine("Error selecting WIA device."); 
      wiaSession.Shutdown(); 
      return; 
   } 
 
   // Initialize and fill the required fields from the WiaAcquireOptions structure 
   WiaAcquireOptions wiaAcquireOptions = WiaAcquireOptions.Empty; 
   wiaAcquireOptions.MemoryBufferSize = 32 * 1024; 
   wiaAcquireOptions.DoubleBuffer = true; 
   wiaSession.AcquireOptions = wiaAcquireOptions; 
 
   wiaSession.AcquireEvent += new EventHandler<WiaAcquireEventArgs>(wiaSession_AcquireEvent); 
 
   wiaSession.Acquire(parent, null, WiaAcquireFlags.ShowUserInterface | WiaAcquireFlags.UseCommonUI); 
 
   wiaSession.AcquireEvent -= new EventHandler<WiaAcquireEventArgs>(wiaSession_AcquireEvent); 
   wiaSession.Shutdown(); 
} 
 
public void wiaSession_AcquireEvent(object sender, WiaAcquireEventArgs e) 
{ 
   Application.DoEvents(); 
 
   if ((e.Flags & WiaAcquiredPageFlags.StartOfPage) == WiaAcquiredPageFlags.StartOfPage) 
      Console.WriteLine("Beginning of data transfer."); 
   else if ((e.Flags & WiaAcquiredPageFlags.EndOfPage) == WiaAcquiredPageFlags.EndOfPage) 
      Console.WriteLine("End of data transfer."); 
 
   if (e.Image != null) 
   { 
      // You can load the image here. 
   } 
 
   e.Cancel = false; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Wia Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.