VintaSoft Twain .NET SDK Discussions
Questions, comments and suggestions concerning VintaSoft Twain .NET SDK.
Board index < VintaSoft Twain < VintaSoft Twain .NET SDK Discussions
<script language="JavaScript" type="text/javascript">
function StartScan()
{
// check that DeviceManager1 object is initialized properly
if (DeviceManager1.IsTwainAvailable == null)
{
document.getElementById('ErrorString').innerHTML = "<a href=https://www.vintasoft.com/vstwain-dotnet-faq.html#Web_DotNetSecurityError>Click here to see how to set the .NET Framework Security settings</a>";
alert("Your .NET Framework Security settings must be configured to run the components in your browser.");
return;
}
document.FormHttp.ScanImagesButton.disabled = 1;
var imageCounter = 0;
try
{
// open the data source manager
DeviceManager1.Open();
// select the device
if (DeviceManager1.Devices.Select())
{
// get a reference to current device
var device = DeviceManager1.Devices.Current;
// enable/disable the User Interface of device
device.ShowUI = document.FormHttp.ShowUI.checked;
// store only one image in the internal buffer of device
device.AcquiredImages.Capacity = 1;
// gray
// open the device
device.Open();
device.PixelType = 0;
try
{
// specify how many images application wants to get from the device
if (document.FormHttp.ScanAll.checked == false)
device.XferCount = 1;
else
device.XferCount = -1;
}
catch (ex)
{
}
// enable document feeder if necessary
if (device.IsFeederPresent)
{
try
{
device.DocumentFeeder.Enabled = document.FormHttp.Adf.checked;
}
catch (ex)
{
alert("Feeder cannot be enabled or disabled.");
}
}
// acquire image(s) from the device
var acquireModalState;
var acquiredImage;
var acquireStatusString = "Scan canceled";
do
{
acquireModalState = device.AcquireModal();
// image acquired
if (acquireModalState == 2)
{
// upload acquired image to the server
acquiredImage = device.AcquiredImages.Last;
acquiredImage = acquiredImage.Despeckle(8,25,30,400);
acquiredImage = acquiredImage.Deskew(0, 5, 5);
acquiredImage = acquiredImage.DetectBorder(5);
imageCounter = imageCounter + UploadToHttpServer(acquiredImage);
}
// scan completed
else if (acquireModalState == 3)
acquireStatusString = "Scan completed";
// scan failed
else if (acquireModalState == 4)
acquireStatusString = "Scan failed";
// scan canceled
else if (acquireModalState == 5)
acquireStatusString = "Scan canceled";
}
while (acquireModalState != 0)
}
}
catch (ex)
{
alert(ex.message);
}
finally
{
// disable the device if device is enabled
if (device.State == 2)
device.Disable();
// close the device if device is opened
if (device.State == 1)
device.Close();
// scan process is finished
alert(acquireStatusString + ": " + imageCounter + " images are uploaded onto the server.");
document.FormHttp.ScanImagesButton.disabled = 0;
}
}
</script >
What I missing?