TwainControl



Platforms:

Windows XP, Vista, 7, 8, Server from 2003 to 2012

Supports Barcode Decoding
Linear:

Interleaved 2/5, Industrial 2/5, Code 39, Code 39 Extended, Codabar, Code 11, Code 128, Code 128 Extended, EAN/UCC 128, UPC-E, UPC-A, EAN-8, EAN-13, Code 93, Code 93 Extended, DataBar Omnidirectional (RSS-14), DataBar Truncated (RSS-14 Truncated), DataBar Limited (RSS Limited), DataBar Stacked, DataBar Expanded, DataBar Expanded Stacked.
2D:
PDF417
QRCode
DataMatrix
Aztec Code

Twain Control Information

Twain Control documentationSee Twain Control documentation.

TwainControl is extremely easy to use. You just add a few lines of code to your app and then you are ready to get images from any Twain device.

Example 1. Acquire image and save it in the image file.

[VB6]

    Dim twain As TwainControl
    Set twain = CreateObject("TwainControlAx.TwainControl.1")

    twain.Connect (twain.Devices.Item(0).Id)

    twain.GetImage
    
    twain.JPEGQuality = 90
    
    twain.SaveImage ("c:\MyImage.jpg")
    


Example 2. Acquire image and save it in the PDF file.

[VB6]

    Dim twain As TwainControl
  
    Set twain = CreateObject("TwainControlAx.TwainControl.1")

    twain.Connect (twain.Devices.Item(0).Id)

    twain.GetImage
    
    twain.SavePDF ("c:\My.pdf")
    


Example 3. Enumerate Twain devices.

[VB6]

    For i = 0 To twain.Devices.length - 1
        Dim dev As Device
        Set dev = twain.Devices.Item(i)
        MsgBox dev.Id & "-" & dev.ProductName
    Next i
    


Example 4. Find barcode using Twain devices.

[VB6]

    Call TwainControl1.Connect(TwainControl1.Devices.Item(Combo1.ListIndex).Id)

    TwainControl1.ResolutionX = 100
    TwainControl1.ResolutionY = 100
    TwainControl1.ImageType = itGrayScale

    TwainControl1.GetImage
    
    'TwainControl1.BarcodeSetProperty "DataMatrixSymbologyID", 1
    TwainControl1.BarcodeTypes = TwainControl1.BarcodeTypes Or DataMatrix Or PDF417
    TwainControl1.BarcodeScan

    For i = 0 To TwainControl1.Barcodes.length - 1
        Dim bc As Barcode
        Set bc = TwainControl1.Barcodes.Item(i)
        MsgBox bc.Text
    Next i
    


Example 5. Gets image from Twain device.

[C#]

    axTwainControl1 = new AxTwainControlAxLib.AxTwainControl();

    axTwainControl1.Connect(axTwainControl1.Devices.item(0).Id);

    axTwainControl1.GetImage();

    axTwainControl1.JPEGQuality = 50;
    axTwainControl1.SaveImage("c:\\1.jpg");
    


Example 6. Gets image from Twain device.

[Internet Explorer, vbscript]

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>TwainControl test page www.twaincontrol.datasymbol.com</title>

<SCRIPT LANGUAGE="vbscript">
    sub OnPageLoad
        set objSelect = Document.getElementById("twainDevices")
        For i = 0 To TwainControl.Devices.length - 1
            Set dev = TwainControl.Devices.Item(i)
            'MsgBox dev.Id & "-" & dev.ProductName
            set optObj = document.createElement("option")
            optObj.text = dev.ProductName
            optObj.value = dev.Id
            objSelect.add optObj
        Next
        
        objSelect.selectedIndex = 0
    End sub
</SCRIPT>

</head>

<body onload="OnPageLoad">

<object id="TwainControl" WIDTH="400" HEIGHT="500"
  classid="clsid:68D1FD53-CE16-4B76-B892-47791F8AC6C4"
  type="application/x-oleobject"></object>

<SCRIPT LANGUAGE="vbscript">
    sub Start
        set objSelect = Document.getElementById("twainDevices")
        if objSelect.length = 0 then
            MsgBox "no devices"
            exit sub
        end if

        TwainControl.Connect objSelect.options.item(0).value
        TwainControl.GetImage
        TwainControl.StretchImage = true
        TwainControl.SaveImage("c:\MyImage.jpg")
    End sub
</SCRIPT>

<br><br>

<select name="twainDevices">
</select>

<br><br><br>
<input LANGUAGE="vbscript" TYPE="button" VALUE="Get Image" ONCLICK="Start" NAME="B1">
<input LANGUAGE="vbscript" TYPE="button" VALUE="About" ONCLICK="TwainControl.AboutBox" NAME="B3">

</body>
</html>





Copyright © 1999-2017, RKD Software & RKD System Inc., All rights reserved.
All trademarks mentioned are the property of their respective owners.