This sample source code below will demonstrate you how to extract text from areas in VBScript and VB6. ByteScout Text Recognition SDK: the SDK designed to help developers in quick implementation of high quality OCR text recognition from scanned images and pdf. It can extract text from areas in VBScript and VB6.
This rich sample source code in VBScript and VB6 for ByteScout Text Recognition SDK includes the number of functions and options you should do calling the API to extract text from areas. This VBScript and VB6 sample code is all you need for your app. Just copy and paste the code, add references (if needs to) and you are all set! Enjoy writing a code with ready-to-use sample codes in VBScript and VB6.
Our website provides trial version of ByteScout Text Recognition SDK for free. It also includes documentation and source code samples.
' Create and activate TextRecognizer object Set textRecognizer = CreateObject("ByteScout.TextRecognition.TextRecognizer") textRecognizer.RegistrationName = "demo" textRecognizer.RegistrationKey = "demo" Set comHelpers = textRecognizer.ComHelpers inputDocument = "..\..\areas-sample.pdf" pageIndex = 0 outputDocument = "result.txt" ' Load document (image or PDF) textRecognizer.LoadDocument(inputDocument) ' Set the location of OCR language data files textRecognizer.OCRLanguageDataFolder = "c:\Program Files\ByteScout Text Recognition SDK\ocrdata_best\" ' Set OCR language. ' "eng" for english, "deu" for German, "fra" for French, "spa" for Spanish, etc. - according to files in "ocrdata" folder ' Find more language files at https://github.com/bytescout/ocrdata textRecognizer.OCRLanguage = "eng" ' Get page size (in pixels). Size of PDF document is computed from PDF Points ' and the rendering resoultion specified by `textRecognizer.PDFRenderingResolution` (default 300 DPI) Dim pageWidth, pageHeight pageWidth = textRecognizer.GetPageWidth(pageIndex) pageHeight = textRecognizer.GetPageHeight(pageIndex) ' Add area of interest as a rectangle at the top-right corner of the page textRecognizer.RecognitionAreas.Add pageWidth / 2, 0, pageWidth / 2, 300 ' Add area of interest as a rectangle at the bottom-left corner of the page, ' and indicate it should be rotated at 90 deg textRecognizer.RecognitionAreas.Add 0, pageHeight / 2, 300, pageHeight / 2, comHelpers.AreaRotation_Rotate90FlipNone ' Now you can get recognized text for further analysis as a list of objects ' containing coordinates, object kind, confidence. Set ocrObjectList = textRecognizer.GetOCRObjects(pageIndex) For Each ocrObject in OCRObjectList WScript.Echo ocrObject.Text & " [" & ocrObject.X & ", " & ocrObject.Y & ", " & ocrObject.Width & ", " & ocrObject.Height & "] : " & ocrObject.Confidence Next ' ... or you can save recognized text pieces to file textRecognizer.KeepTextFormatting = False ' save without formatting textRecognizer.SaveText outputDocument, pageIndex, pageIndex WScript.Echo "Extracted text saved to " + outputDocument Set recognizer = Nothing