AnyCPU & Bridgex86 Examples
Learn how to use TwainScanning.NET with 64-bit applications and 32-bit scanner drivers using our Bridgex86 technology.
What is Bridgex86?
Bridgex86 is our solution for using TwainScanning with 32-bit scanner drivers in 64-bit applications. Previously, this wasn't possible because 64-bit applications can't directly interface with 32-bit scanner drivers.
While Bridgex86 has a slightly simplified API compared to our standard 32-bit library, it supports all essential scanning operations and provides a streamlined workflow that's easy to implement.
Bridgex86 Examples
Discovering Scanners
List all installed scanners and identify the default scanner.
var allScannersResult = Bridgex86.GetAllDevices(); // gets all installed scanners
if (allScannersResult.Status == StatusType.OK)
{
Console.WriteLine("Found scanners:");
foreach (var scanner in allScannersResult.Value) // Value property holds all scanners
Console.WriteLine(scanner);
}
else
{
Console.WriteLine("No scanners found!");
}
var defaultScannerResult = Bridgex86.GetDefaultDevice(); // gets the default scanner
if (defaultScannerResult.Status == StatusType.OK)
{
Console.WriteLine("Default scanner is: " + defaultScannerResult.Value);
}
else
{
Console.WriteLine("No default scanner found!");
}
Scanner Capabilities
Get all supported capabilities and check if specific features are available.
// if scanner is omitted then the default scanner is used
var allCapsResult = Bridgex86.GetAllSupportedCapabilities(scanner);
Console.WriteLine("Supported capabilities:");
foreach (var cap in allCapsResult.Value)
Console.WriteLine(cap);
var pageSupportResult = Bridgex86.GetIsSupportedCapability("PageSize", scanner);
bool isSupported = pageSupportResult.Value;
if (isSupported)
Console.WriteLine("PageSize capability is supported");
else
Console.WriteLine("PageSize capability is not supported");
var pagesResult = Bridgex86.GetSupportedPageSizes(scanner);
Console.WriteLine("Supported page sizes:");
foreach (var page in pagesResult.Value)
Console.WriteLine(page);
Scanning Documents
Configure scan settings, execute the scan, and handle the results.
string scanner = "MyScanner";
string outputFileName = @"C:\SomeFolder\scanned_document.jpeg";
var settings = new ScanSettings(); // holds all scan settings
settings.Device = scanner; // default scanner is used if omitted
settings.TransferMechanism = TwSX.Native;
var pgCap = Bridgex86.GetSupportedPageSizes(scanner);
settings.PageSize = (TwSS)Enum.Parse(typeof(TwSS), pgCap.Value[0]);
var scanResult = Bridgex86.Acquire(outputFileName, settings);
// Check status and display related messages
if (scanResult.Status == StatusType.OK)
{
Console.WriteLine("Scan successful!");
}
else if (scanResult.Status == StatusType.Warning)
{
Console.WriteLine("Scan completed with warnings:");
Console.WriteLine(scanResult.WarningMessages);
}
else if (scanResult.Status == StatusType.Error)
{
Console.WriteLine("Scan failed:");
Console.WriteLine(scanResult.ErrorMessages);
}
Ready to Get Started?
Download the free trial and start integrating scanner support into your 64-bit .NET applications today.