LEADTOOLS Recognition Imaging SDK – I had the pleasure of taking the SDK for a spin, and let me tell you it was well worth it. LEADTOOLS has already established itself as a world leader in Imaging SDK’s, but for me it goes much further than just that. The technical support is stellar! This is what differentiates a good functional product from a stunning product.
LEADTOOLS Recognition Imaging
Before I delve into the code, I have to highlight the LEADTOOLS technical support team. I had an issue I couldn’t resolve myself. I emailed LEAD’s technical support and received a reply from them a few hours later. The support agent assigned to my case gave me several different solutions that I could try. This single email resolved my issue on the spot. This is where the watershed exists for many products. Great tools without great support is meaningless. LEADTOOLS surpassed my expectations and treated my support request with a complete and technically sound reply. I felt as if I had purchased the product (remember, I only have the trial version here).
LEADTOOLS Recogntion Imaging – Setting Up Your Code
I am using Visual Studio 2013 with a basic Windows Forms application. With LEADTOOLS, you can of course create web applications that harness the power of their Imaging SDK too. To start off, you will need to add the following using statements to your application.
Then in the constructor you need to set up the licensing for your SDK. To do this you need to define a path to your license file as well as define your developer key. You then call the LeadTools.RasterSupport class that provides the methods for you to set your LEADTOOLS runtime license. This also unlocks support for optional LEADTOOLS features such as LEADTOOLS Document/Medical capabilities.
Converting a TIFF to a Searchable PDF Document
To see how easy it is to convert a TIFF to a text-searchable PDF document, I created the following app. All it does is read a TIFF file and processes that through the IOcrEngine. Clicking on the ‘Tiffs to PDF’ button will start to process the TIFF file.
The TIFF file is then converted into a PDF document. I used the LEADTOOLS Document Viewer to display the created PDF document. You will notice that the Document Viewer also displays thumbnails of the generated PDF document.
When I open the created PDF document in Acrobat Reader, you can see that the PDF document is a fully valid and searchable PDF document.
The code to accomplish this is just as simple. In the MultiTiff() method, I create an instance of the IOcrEngine. The engine is then started passing null as a parameter. Be sure to add a reference to the ‘Leadtools.Forms.Ocr.Advantage’ dll in your project. Then run the AutoRecognizeManager passing it the path to the TIFF file and the file name of the PDF document you want to create.
In the button click event ‘Tiffs to PDF’, the following code is used to create a split container that will display the generated PDF document as well as the thumbnail container. I then loaded the created PDF document into my DocumentFactory object. The result is a beautifully generated and displayed PDF document with minimal code.
Consider the following application: reading multiple TIFF files and converting all these into PDF Documents. The use of this code logic is very powerful.
If you run into the following exception ‘Raster PDF Engine is needed to use this feature’, you need to locate the Leadtools.PdfEngine.dll in the LEADTOOLS installation directory (usually located at ‘C:LEADTOOLS 19Bin’ in one of the Dotnet subfolders). Copy this DLL and paste it into the bin folder of your application, or add it to the project and set its Build Action to “Content” and Copy to Output Directory to “Copy Always.” You can also copy the LeadTools.PdfEngine.dll to a common directory and use the InitialPath method to tell LEADTOOLS to locate and load the PDF Engine from the DLL at the given path. You can read more at the following support article ‘InitialPath Property‘.
You can also specify that LEADTOOLS only recognize a specific zone from a loaded TIFF file. I am using the Advantage OCR Engine here. The application also uses a split container with a LEADTOOLS Raster Image Viewer control in the top panel, and a plain old text box in the bottom panel.
Clicking on the ‘Load Image’ button will load the TIFF file (the same TIFF I used as example above) and display it in the Raster Image Viewer control. This is where you can now use your mouse and select a zone of text for the OCR engine to recognize. When you click on the ‘Read Zone’ button, the text is output to the text box in the bottom panel.
Here is a closer view of the selected zone and the text it recognized which is output to the text box. As you can see, this is quite accurate.
The code to accomplish this is also a walk in the park. In the ‘Load Image’ button logic all I am doing is setting the Raster Image Viewer to the codec loaded with the TIFF image at the given path. My button click just called the method ‘LoadImage’ and passed it the path to the TIFF file.
The ‘ReadFileZone’ method first checks that a zone is selected in the loaded TIFF file and then proceeds to create the Advantage OCR Engine. You will see that the engine starts up and a page is then created from the image in the Raster Image Viewer. After that, the zone I selected with my mouse is then identified and recognized. The recognized text is then output to the text box in the split container. Easy peasy lemon squeezy.
Consider the following application: Recognizing text on a standard document by pre-selecting zones automatically and saving these zones to a data store such as a SQL Server database. You can then provide a digital copy of multiple forms that are searchable from the database in a snap.
“Disclosure of Material Connection: I received one or more of the products or services mentioned above for free in the hope that I would mention it on my blog. Regardless, I only recommend products or services I use personally and believe my readers will enjoy. I am disclosing this in accordance with the Federal Trade Commission’s 16 CFR, Part 255: “Guides Concerning the Use of Endorsements and Testimonials in Advertising.”