ASP.NET Core enables C# application to run on *nix operating systems. In this tutorial, we are going to play with ASP.NET Core and Dynamic Web TWAIN SDK to build a DotNet Core document scanning application for Windows, Linux, and macOS.Read more
Wrapping a HTML element as an component is a new fashion of front-end development. In this article, we will take a tour of building a component-based document scanning app using Vue.js and Dynamic Web TWAIN. To make our app look modern, we hire Vuetify, one of the most popular libraries, to build our UI.Read more
Dynamic .NET TWAIN is one of the excellent TWAIN-compliant SDKs for document scanning and image capture. In this tutorial, I would like to share how to create a bridge to convert .NET TWAIN C# methods to Java methods in order to help Java developers easily implement Java TWAIN scanner software.
Dynamic .NET TWAIN 5.0 has been released for a while. To help users to quickly grasp APIs, a brand-new API demo, written in WPF with C# & VB.NET, is included. In this tutorial, we would like to show the anatomy of this application. Let’s glance at the screenshot as a warm up. As you can see, the functionalities of the demo include scanner control, image loading, barcode recognition, OCR, image manipulation and processing.
How to install Dynamic .NET TWAIN 5.0?
Visit Dynamic .NET TWAIN page and get the installation package by clicking “Download” button. Follow the InstallShield Wizard step by step.
Where is the API demo?
The demo source code is located at “…\Dynamsoft\Dynamic .NET TWAIN 5.0 Trial\Samples\C# Samples\VS 12” and “…\Dynamsoft\Dynamic .NET TWAIN 5.0 Trial\Samples\VB .NET Samples\VS 12\WpfControlsDemo”. You can choose your preferred programming language, C# or VB.NET.
What does the project look like in Visual Studio?
The reference DynamicDotNetTWAIN.Wpf.dll is located at “…\Dynamsoft\Dynamic .NET TWAIN 5.0 Trial\Samples\Bin”. It will be copied to your project folder when you run the Visual Studio solution file “WpfControlsDemo.sln”. If you want to create your own project, don’t forget to add it. In this project, we have created three windows. The main window is “Window1.xaml”.
How to use the relevant APIs to implement following functions?
All implementation logics are same no matter which language you choose. Let’s illustrate with C#.
We’re proud to reveal that Dynamsoft’s Dynamic .NET TWAIN 5.0 is on its way to release soon. In addition to WinForms support, the new version will include a WPF control. You can use it in your WPF app to capture images from TWAIN scanners and UVC/WIA webcams, to edit and save images to local disks, to a server or a database. Today, I’d like to cover how, using VB.NET, you can use the Dynamic .NET TWAIN 5.0 SDK to implement barcode reading in a WPF application.
The relevant source code can be downloaded here.
1. Create a New WPF Project
First, start Visual Studio .NET, and create a new WPF project. Select Visual Basic as the type and choose WPF Application as the template.
2. Add a Reference
Right-click on the project root, and select Add Reference… from the menu. Click Browse to locate DynamicDotNetTWAIN.dll and add it.
3. Add Dynamic .NET TWAIN Component
If there is no Dynamic .NET TWAIN component available, you might need to open the toolbox. To do so, right-click on the panel and select Choose Items… Switch to the tab WPF Components and click Browse… to load DynamicDotNetTWAIN.Wpf.dll
4. Add Buttons and Textbox
Next, you’ll want to drag two buttons and one textbox from the toolbox to design a form. The buttons are used to load an image and make the detection of a barcode. And, the textbox is used to display the information decoded from barcode.
5. Code for Loading Image
Now, what you need to do is to acquire an image using the Windows standard API. Then you’ll need to load it using the Dynamic .NET TWAIN component method. Just a couple of lines of code are needed for loading an image. It’s pretty simple.
Dim filedlg As OpenFileDialog filedlg = New OpenFileDialog() filedlg.Multiselect = True Dim strFilename As String If (filedlg.ShowDialog() = DialogResult.OK) Then For Each strFilename In filedlg.FileNames DynamicDotNetTwain1.LoadImage(strFilename) Next End If
6. Code for Barcode Recognition
To decode a barcode, the path for the barcode library needs to be first be specified. Then, with one additional line of code, you’ll get results.
Set the path of barcode library
Dim strDllFolder As String strDllFolder = Application.ExecutablePath Dim pos As Integer pos = strDllFolder.LastIndexOf("\Samples\") If (pos <> -1) Then strDllFolder = strDllFolder.Substring(0, strDllFolder.IndexOf("\", pos)) + "\Bin\BarcodeResources\" End If Me.DynamicDotNetTwain1.BarcodeDllPath = strDllFolder
Get the results and display them on screen
Me.TextBox1.Text = "" Dim aryResult() As Result aryResult = Me.DynamicDotNetTwain1.ReadBarcode(Me.DynamicDotNetTwain1.CurrentImageIndexInBuffer, BarcodeFormat.All) Dim strText As StringBuilder strText = New StringBuilder() If aryResult.Length = 1 Then strText.AppendFormat(aryResult.Length & " total barcode" & ("") & " found." & Constants.vbCrLf) Else strText.AppendFormat(aryResult.Length & " total barcode" & ("s") & " found." & Constants.vbCrLf) End If For i As Integer = 0 To aryResult.Length - 1 Dim objResult As Result objResult = aryResult(i) strText.AppendFormat(" Result " & (i + 1) & Constants.vbCrLf) strText.AppendFormat(" BarcodeFormat: " & objResult.BarcodeFormat.ToString() & Constants.vbCrLf) strText.AppendFormat(" Text read: " & objResult.Text & Constants.vbCrLf) Next i Me.TextBox1.Text = strText.ToString()
I hope this brief tutorial is helpful to anyone who is looking for a .NET barcode reader SDK in VB.NET.
For further inquiries, please feel free to send me an email at kgao[at]dynamsoft.com.
Dynamic .NET TWAIN 5.0 is scheduled to be released late next month. To stay informed about all our product announcements, blog posts and more, be sure to follow us on Twitter, like us on Facebook or add us on Google+. Also, if you’d like to be amongst the first to try out the new version first, please contact support[at]dynamsoft.com.
I’m pleased to announce that Dynamic Web TWAIN 9.1 is released on August 27th, 2013.
Three exciting improvements are included in this new version:
- Added native scanning support for Mac Edition. The new property ImageCaptureDriverType allows Mac users to directly acquire images via native scan (without installing a TWAIN driver).
- Improved IE users’ experience when using a separate process for document scanning. In v9.0, IE users might need to manually allow the broker process to run. It is now automated with the enhanced security of the ActiveX edition.
- Fixed a bug where OnPostTransfer event is not triggered in some cases.
I’d love to hear any comments or suggestions about this new version. Please don’t hesitate to contact me (email@example.com).
You may get problems when using your application with some scanners and wonder whether it is the issue with your application or it is the device issue.
If you are using a TWAIN library and your application is supposed to work with all TWAIN compatible devices, you can use Twacker, which is a TWAIN application developed by The TWAIN Working Group. It allows you to exercise features of a TWAIN driver and to see whether the driver of your device is working fine or not.
You can download Twacker installers here:
How to use Twacker?
After the installation, you can follow the steps below to test your scanners.
- Launch Twack. Go to Windows Start menu and type Twack.
- Connect to your scanner. Click menu File-> Select Source and you will see all the available sources available on your machine.
- Test your scanner.Under File menu, check ShowUI to show the user interface of the device.
With UI hidden, you can use the Automatic Feeding setting to test ADF scanning.
Click Acquire to initiate scanning and see how your device works.
- TroubleshootIf you fail to acquire images from your scanner using Twacker, you can adjust the Message Level to see if you can get more information to pinpoint the cause of the issue.
Under Special menu, you can also check the TWAIN State transition info.
Another easy way to test your TWAIN device online
You can also test your scanner using the online demo of Dynamic Web TWAIN, which is a browser-based TWAIN SDK. You only need to install an ActiveX/Plug-in for your browser (Internet Explorer/Chrome/Firefox, Safari) and have a quick check for your scanner online.
Since Internet Explorer 7 on Windows Vista was released, Protected Mode has been introduced as a new security feature. When running in Protected Mode, Internet Explorer is a low integrity process and has limited permissions to access the user system.
When running Dynamic Web TWAIN, the scanner browser plugin for web application, on Windows Vista and above, IE Protected Mode is on by default so users consistently get issues like the following:
- ActiveX failed to access the scanners connected to the user machine
- IE crashed when ActiveX tries to acquire images from scanner due to insufficient permission
With Dynamic Web TWAIN v9.0, you can now use an independent broker process to communicate with the scanners for better compatibility and robustness.
- Avoid browser crashes caused by scanner driver problems, thus improving the robustness of the web application. The independent process will not affect the browser process.
- The independent process used for scanning has a higher permission level than the browser process. This can solve the scanning issues, such as browsers not accessing the scanner source successfully, caused by the increased security features of Windows/IE.
Read more: How to work with IE Protected Mode?