←Select platform

AcquirePage Event

Summary
Occurs for each page acquired from the currently selected TWAIN source using the Acquire method.

Syntax
C#
C++/CLI
Python
public event EventHandler<TwainAcquirePageEventArgs> AcquirePage 
public: 
event EventHandler<TwainAcquirePageEventArgs^>^ AcquirePage 
def AcquirePage(sender,e): # sender: TwainSession e: TwainAcquirePageEventArgs 
Event Data

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

PropertyDescription
Cancel Set to true to abort the acquire operation.
Image Gets the IRasterImage which holds the image data acquired from the TWAIN Data Source.
Remarks

If the user acquired several pages at the same time, a separate event occurs for each page. The GetInformation method can only be called within this event. For more information, refer to How to Acquire from the Twain Source.

Example
C#
using Leadtools; 
using Leadtools.Twain; 
 
 
TwainSession acq_session; 
private void twain_AcquirePage(object sender, TwainAcquirePageEventArgs e) 
{ 
   // get acquired image here 
 
   // call StopFeeder method here if you need to stop the feeder 
   acq_session.StopFeeder(); 
} 
 
public void AcquireExample(IntPtr parent) 
{ 
   acq_session = new TwainSession(); 
   acq_session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None); 
 
   acq_session.SelectSource(String.Empty); 
 
   TwainProperties props = acq_session.Properties; 
   TwainDataTransferProperties dataProps = props.DataTransfer; 
   dataProps.FileName = Path.Combine(LEAD_VARS.ImagesDir, "twain.bmp"); 
   dataProps.MemoryBufferSize = dataProps.MemoryBufferSize * 2; 
   props.DataTransfer = dataProps; 
   acq_session.Properties = props; 
   TwainTransferOptions opts = acq_session.TransferOptions; 
 
   acq_session.AcquirePage += new EventHandler<TwainAcquirePageEventArgs>(twain_AcquirePage); 
 
   if (acq_session.Acquire(TwainUserInterfaceFlags.Show) != DialogResult.OK) 
      MessageBox.Show("Error Acquiring From Source"); 
 
   acq_session.Shutdown(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

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

Leadtools.Twain Assembly

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