The BLACKICE_MESSAGE_OCR message is available since Printer Driver version 14.98.
The printer driver transfers the OCR data through this message if the “Generate OCR output in memory” option is enabled. The OCR data is generated for each printed page separately.
Parameters:
wParam:
A handle to the TSPrnMessage structure. Use the GlobalLock WinAPI function to get a pointer to a TSPrnMessage structure:
TSPrnMessage* pPrnMsg = (TSPrnMessage*)GlobalLock((HGLOBAL)wParam);
If you do not need the TSPrnMessage structure anymore, free it using the GlobalUnlock and GlobalFree functions:
GlobalUnlock((HGLOBAL)wParam);
GlobalFree((HGLOBAL)wParam);
The definition of the TSPrnStructure is available on the following page: http://www.blackice.com/private/rtk/The_Message_Capture_Library_Reference.htm
The valid members of the TSPrnMessage structure for the “BLACKICE_MESSAGE_ OCR” messages are the dwMessage, szDocName, szPrinterName, dwJobID, nPageNumber and dwOCRDataFormat fields of the TSPrnMessage structure.
The dwOCRDataFormat member of the TSPrnMessage structure contains the type of the OCR data. It can be one of the following values:
BI_OCR_MEM_FORMAT_TEXT (1): Plain Text format
BI_OCR_MEM_FORMAT_HOCR_HEADER (2): Header of the hOCR data
BI_OCR_MEM_FORMAT_HOCR_PAGE (3): hOCR data for the page
BI_OCR_MEM_FORMAT_HOCR_FOOTER (4): Ending part of the hOCR data
The Black Ice Printer Drivers support Plain Text and hOCR output formats for the OCR.
If the Plain Text output format is selected, the printer driver will send a BLACKICE_MESSAGE_OCR message after each BLACKICE_MESSAGE_STARTPAGE message, containing the OCR text (BI_OCR_MEM_FORMAT_TEXT) for the page.
If the hOCR output format is selected, the printer driver will send a BLACKICE_MESSAGE_OCR message before the first BLACKICE_MESSAGE_STARTPAGE message, containing the header part of the hOCR data (BI_OCR_MEM_FORMAT_HOCR_HEADER).
Then the driver will send a BLACKICE_MESSAGE_OCR message after each BLACKICE_MESSAGE_STARTPAGE message, containing the hOCR data for the page (BI_OCR_MEM_FORMAT_HOCR_PAGE).
Finally, the driver will send a BLACKICE_MESSAGE_OCR message after the last BLACKICE_MESSAGE_ENDPAGE message, containing the footer part of the hOCR data (BI_OCR_MEM_FORMAT_HOCR_FOOTER).
lParam:
The lParam parameter of the message contains a handle to the OCR data.
To get the pointer to the OCR data, use the GlobalLock WinAPI function. The OCR data is a NULL terminated Unicode string:
LPWSTR pOCRData = GlobalLock((HGLOBAL)lParam);
To get the size of the OCR data including the terminating NULL character, use:
DWORD dwSize = (DWORD)GlobalSize((HGLOBAL)lParam);
If the OCR data is not needed anymore, free it using:
GlobalUnlock((HGLOBAL)lParam);
GlobalFree((HGLOBAL)lParam);