OCRDIBToFile Method

Description  

This function OCR the specified DIB and saves the output text to the specified output text file. If the file already exists the function will overwrite the file.      

Syntax                 RetVal = [BIOCR.] OCRDIBToFile  hDIB szFileName bAppend szLanguage bDetectOrientation nEncoding

Returns               RetVal                          Integer          Returns with error status. OCR_OK (0) if successful. See other error codes in BiOCR.ocx specific error codes.

Code example

// C# code

 

BIOCRLib.BiOCRClass ocrLib = new BIOCRLib.BiOCRClass();

BIDIBLib.BIDIBClass dibLib = new BIDIBLib.BIDIBClass();

int ret = 0;

long dib = 0;

 

// Load the image into DIB

dib = dibLib.LoadImageIntoDIB("c:\\Program Files\\Black Ice Software LLC\\Document Imaging SDK DEMO for Windows 32-bit\\Images\\TEST.TIF", 0);

 

// Check error

if (dib == 0)

    return;

 

// OCR the DIB to file

ret = ocrLib.OCRDIBToFile(dib, "c:\\OCR_test.txt", 0, "eng", 1, (int)BIOCRLib.OCR_TEXT_ENCODING.OCR_ENC_UTF8);

 

// Check error

if (ret != (int)BIOCRLib.OCR_ERRORS.OCR_OK)

    return;              

Remarks            

hDIB               LONGLONG             Handle of the DIB to OCR

szFileName     String              The output text file name

bAppend        Boolean           If TRUE the function will append the output text to the end of output file
If FALSE the function will overwrite the output file if the output file already exists

szLanguage    String              The code of the language used for OCR. If multiple languages are used the language codes must be separated by ‘+’ character. The available languages can be retrieved by the GetOCRLanguages function. See the languages codes in the OCR languages section

bDetectOrientation    Boolean           If TRUE the function will detect the text orientation automatically.
                                                            If FALSE the function will assume that the text in the DIB is not rotated. (this mode is faster)

nEncoding                  Integer             The used character encoding for the output file
If         0          OCR_ENC_ASCII                 use ASCII encoding
If         1          OCR_ENC_UTF8                  use UTF-8 encoding
If         2          OCR_ENC_UTF16                use UTF-16 encoding