1. What is TWAIN?
TWAIN is a protocol and Application Programming Interface (API) that
standardizes communication between an application and image acquisition devices
such as scanners and digital cameras. This standard allows a developer to make
standard calls to any image acquisition device that supports TWAIN. Thus the
application would not have to be rewritten to support every device. TWAIN has
been in existence since 1992 and is governed by the TWAIN Working Group.
2. What is Dynamic .NET TWAIN?
Dynamic .NET TWAIN is a .NET component which enables you to acquire images from any TWAIN compatible devices.
It is specially designed for Microsoft .NET Framework-based desktop scanning applications. It enables you to acquire images from any TWAIN compatible devices.
With the carefully designed interface, and the built-in wizard mode, Dynamic .NET TWAIN is very easy to use. You can typically do your TWAIN job in several lines of code. At the same time, Dynamic .NET TWAIN is very powerful. It is compatible with TWAIN specification V1.9. It supports all three image transfer modes and many other features.
3. For which
purposes can I use Dynamic .NET TWAIN?
Dynamic .NET TWAIN is designed for Microsoft .NET Framework-based desktop scanning applications. It can be used for controlling any work of scanners, digital
cameras and any other devices which support TWAIN standard. Dynamic .NET TWAIN
can upload and download images through FTP(S) or HTTP(S) protocol. Proxy is
supported.
4. Who do I
contact if I need technical support?
7. What is Live Help?
Dynamsoft is committed to providing the best customer support in the
industry. Our support team is ready to offer no time limit, high quality,
friendly and responsively technical support for our valued registered users.
We provide at least 20 hours Live Support per weekday. Live Support is an
online chat service for our customers to interact with our support professional
in real time.
8. Do you provide sample code? If yes,
how can I get it?
Yes, we provide sample code
of Dynamic .NET TWAIN in VB.NET and C#. You can find the samples in program group of Dynamic .NET TWAIN after installation.
9. What operating systems does Dynamic .NET TWAIN work with?
Dynamic .NET TWAIN supports Windows 95, 98, ME, NT, XP, 2000, 2003, Vista, 2008 and Windows 7.
10. What programming languages does Dynamic .NET TWAIN work with?
Dynamic .NET TWAIN can be used with C# and VB.NET.
Dynamic .NET TWAIN is very easy to distribute. You only need to distribute DynamicDotNetTwain.dll with your desktop applications. The DLL file does not need to be registered.
2. What files I need to include in the setup package of my program?
You need DynamicDotNetTwain.dll in the setup package only.
Twain1.OpenSource(); Twain1.IfShowUI = false; Twain1.IfDisableSourceAfterAcquire = true; Twain1.PixelType = Dynamsoft.DotNet.TWAIN.Enums.TWICapPixelType.TWPT_BW; Twain1.AcquireImage();
private void BeginScan()
{
Twain1.OpenSource();
Twain1.IfShowUI = false; // set without user interface
Twain1.IfDisableSourceAfterAcquire = true;
Twain1.AcquireImage();
}
private void Twain1_OnPostTransfer()
{
Twain1.SaveAsBMP("c:\temp.bmp", 0);
}
Twain1.SelectSource(); Twain1.OpenSource(); Twain1.IfShowUI = false;
// Set Image Layout Twain1.Unit = Dynamsoft.DotNet.TWAIN.Enums.TWICapUNits.TWUN_INCHES; // INCHES Twain1.SetImageLayout(0, 0, 5, 5); Twain1.AcquireImage();
Twain1.OpenSourceManager();
int count = Twain1.SourceCount;
for (short lngNum = 0; lngNum < count; lngNum ++)
{
if (Twain1.SourceNameItems(lngNum) == "Specified device name")
{
Twain1.SelectSourceByIndex (lngNum);
break;
}
}
// if can't find the specified source, it'll select default source
Twain1.AcquireImage();
Twain1.IfShowUI = false; Twain1.IfDisableSourceAfterAcquire = true; Twain1.OpenSource(); Twain1.IfShowIndicator = false; Twain1.AcquireImage();
Twain1.SelectSource(); Twain1.OpenSource();
//Set XRESOLUTION current value. Twain1.Capability = Dynamsoft.DotNet.TWAIN.Enums.TWCapability.ICAP_XRESOLUTION; Twain1.CapType = Dynamsoft.DotNet.TWAIN.Enums.TWCapType.TWON_ONEVALUE; Twain1.CapValue = 300; if (Twain1.CapSet() == false) MessageBox.Show("Failed to set the x-resolution.\r\n" + Twain1.ErrorString); //Set YRESOLUTION current value. Twain1.Capability = Dynamsoft.DotNet.TWAIN.Enums.TWCapability.ICAP_YRESOLUTION; Twain1.CapType = Dynamsoft.DotNet.TWAIN.Enums.TWCapType.TWON_ONEVALUE; Twain1.CapValue = 200; if (Twain1.CapSet() == false) MessageBox.Show("Failed to set the y-resolution.\r\n" + Twain1.ErrorString); Twain1.AcquireImage();
The following is a http put method sample:
private void BeginScan()
{
Twain1.AcquireImage();
}
private void Twain1_OnPostTransfer()
{
if (Twain1.HTTPUploadThroughPut("127.0.0.1", 0, "httpUploadFileTemp.bmp") == false)
MessageBox.Show(Twain1.ErrorString);
}
int iDocumentCounter = 0;
private void ADFScan()
{
iDocumentCounter = 0; //set initialize value
Twain1.OpenSource();
Twain1.IfShowUI = false;
Twain1.IfDisableSourceAfterAcquire = true;
if (Twain1.Duplex != Dynamsoft.DotNet.TWAIN.Enums.TWICapDuplex.TWDX_NONE)
Twain1.IfDuplexEnabled = true; //enable duplex
if (Twain1.IfFeederEnabled)
{
Twain1.XferCount = -1;
Twain1.IfAutoFeed = true; //auto feed
if (Twain1.IfFeederLoaded)
Twain1.AcquireImage();
}
}
private void Twain1_OnPostTransfer()
{
iDocumentCounter = iDocumentCounter + 1;
if (!Twain1.SaveAsBMP(@"c:\" + iDocumentCounter.ToString() + ".bmp", 0))
MessageBox.Show(Twain1.ErrorString);
}
You can use the IfSSL property.
Twain1.HTTPPort = 80; Twain1.IfSSL = false; // if 80 is the port number of non-secure port
/* Twain1.HTTPPort = 443; Twain1.IfSSL = true; // if 443 is the port number of secure port */
Twain1.HTTPUploadThroughPost("127.0.0.1", 0, "/SaveToFile.php", "imageData.jpg"); if (Twain1.ErrorCode != Dynamsoft.DotNet.TWAIN.Enums.ErrorCode.Succeed) MessageBox.Show(Twain1.ErrorString); else //succeded MessageBox.Show("Successful");
10. How can I add a new scanned image to an existed multi-page TIFF file?
private void Scan()
{
Twain1.AcquireImage();
}
private void Twain1_OnPostTransfer()
{
Twain1.CloseSource();
Twain1.IfTiffMultiPage = true;
Twain1.SaveAsTIFF (@"C:\SaveAsTIFF.tif", 0);
if (Twain1.ErrorCode != Dynamsoft.DotNet.TWAIN.Enums.ErrorCode.Succeed)
MessageBox.Show(Twain1.ErrorString);
else
MessageBox.Show("Successful");
}
11. How can I rotate an image before I save it?
You can use the RotateLeft
property and the RotateRight
property.
private void Scan()
{
Twain1.AcquireImage();
}
private void RotateLeft()
{
Twain1.RotateLeft(0);
}
private void RotateRight()
{
Twain1.RotateRight(0);
}
private void Rotate()
{
Twain1.Rotate(0, 45.0, true, Dynamsoft.DotNet.TWAIN.Enums.DWTInterpolationMethod.Bicubic);
}
private void Scan()
{
Twain1.AcquireImage();
}
private void Twain1_OnPostTransfer()
{
Twain1.CloseSource();
Twain1.ShowImageEditor();
// You need to save the rotated image in the image editor before closing it
}
12. How can I view a specified image if there are several images in buffer?
You can view a specified image or go through all the images in buffer with clicking "NextImage" or "PreImage" buttons.
private void Next()
{
if (Twain1.HowManyImagesInBuffer == 0)
MessageBox.Show("There is no image in buffer");
Twain1.CurrentImageIndexInBuffer = (short)(Twain1.CurrentImageIndexInBuffer + 1);
}
private void Previous()
{
if (Twain1.HowManyImagesInBuffer == 0)
MessageBox.Show("There is no image in buffer");
Twain1.CurrentImageIndexInBuffer = (short)(Twain1.CurrentImageIndexInBuffer - 1);
}
13. How can I do a duplex scan?
private void DuplexScan()
{
Twain1.SelectSource();
Twain1.OpenSource();
Twain1.IfDuplexEnabled = true; //enable duplex
Twain1.XferCount = 2;
Twain1.MaxImagesInBuffer = 2;
Twain1.AcquireImage();
}
14. How can I scan an inverted image?
You can use the PixelFlavor property.
private void Scan()
{
Twain1.PixelFlavor = Dynamsoft.DotNet.TWAIN.Enums.TWICapPixelFlavor.TWPF_CHOCOLATE;
Twain1.AcquireImage();
}