=== modified file 'cuneiform_src/Kern/cuneiform-cli.cpp'
--- cuneiform_src/Kern/cuneiform-cli.cpp	2009-02-03 10:43:57 +0000
+++ cuneiform_src/Kern/cuneiform-cli.cpp	2009-02-21 16:31:52 +0000
@@ -306,7 +306,21 @@
     PUMA_SetImportData(PUMA_Bool32_DotMatrix, &dotmatrix);
     PUMA_SetImportData(PUMA_Bool32_Fax100, &fax);
 
-    if(!PUMA_XOpen(dib, "none.txt")) {
+	const char* pBegName = ::strrchr(infilename, '/');
+	if (0 == pBegName) {
+		const char* pBeg2 = ::strrchr(infilename, '\\');
+		if (0 != pBeg2) {
+			pBegName = pBeg2 + 1;
+		}
+	}
+	else {
+		++pBegName;
+	}
+	if (0 == pBegName) {
+		pBegName = infilename;
+	}
+	
+	if(!PUMA_XOpen(dib, pBegName ? pBegName : "none_image_name")) {
         cerr << "PUMA_Xopen failed.\n";
         return 1;
     }

=== modified file 'cuneiform_src/Kern/rout/src/html.cpp'
--- cuneiform_src/Kern/rout/src/html.cpp	2008-09-18 11:46:37 +0000
+++ cuneiform_src/Kern/rout/src/html.cpp	2009-02-21 19:53:12 +0000
@@ -70,6 +70,11 @@
 #include "rout_own.h"
 #include "compat_defs.h"
 
+#include <string>
+#include <sstream>
+
+using namespace std;
+
 static BOOL Static_MakeHTML(Handle hObject, long reason);
 
 static BOOL FontStyle(ULONG newStyle);
@@ -106,48 +111,126 @@
     hocrmode = TRUE;
     return BrowsePage(Static_MakeHTML, FALSE, FALSE);
 }
+
+/*!
+\brief \~english Put stream bufer into buffer for OCR results.
+       \~russian Поместить содержимое строкового потока в буфер
+                 результатов распознавания.
+*/
+static BOOL
+strm2buf(const ostringstream& outStrm)
+{
+	unsigned long sizeMem = outStrm.str().size();
+	// проверим достаточность памяти
+	CHECK_MEMORY(sizeMem + 10);
+
+	::memcpy(gMemCur, outStrm.str().c_str(), sizeMem);
+	gMemCur += sizeMem;		
+
+	return TRUE;
+}
+
+/*!
+\brief \~english Put info about hOCR text line into buffer for OCR results.
+       \~russian Поместить текстовую строку hOCR в буфер результатов распознавания.
+*/
+static BOOL
+writeHocrLine(Byte* pLineStart, const edRect& rcLine, const unsigned int iLine)
+{
+	ASSERT(pLineStart);
+	ostringstream outStrm;
+	outStrm << "<span class='ocr_line' id='line_" << iLine << "' "
+		<< "title=\"bbox " 
+		<< rcLine.left << " "
+		<< rcLine.top << " "
+		<< rcLine.right << " "
+		<< rcLine.bottom << "\">";
+	outStrm.write(reinterpret_cast<const char*>(pLineStart), gMemCur - pLineStart);
+	outStrm << "</span>";
+	
+	unsigned long sizeMem = outStrm.str().size();
+	// проверим достаточность памяти
+	CHECK_MEMORY(sizeMem + 10);
+
+	::memcpy(pLineStart, outStrm.str().c_str(), sizeMem);
+	gMemCur = pLineStart + sizeMem;		
+
+	return TRUE;
+}
+
 //********************************************************************
 BOOL Static_MakeHTML(
 			Handle hObject,
 			long reason	// См. enum BROWSE_REASON
 			)
 {
-    char buf[256] = "";
-    edRect r;
-// В конце вызывается WordControl
+	static char buf[256] = {0};
+    //! \~russian прямоугольник символа
+	edRect r = {0}; 
+	
+	static unsigned int iPage(1);
+    //! \~russian прямоугольник строки
+	static edRect rcLine = {0};
+    //! \~russian прямоугольник строки
+	static bool isInLine(false);
+    //! \~russian номер текущей строки
+	static unsigned int iLine(1);
+    //! \~russian позиция начала строки в текстовом буфере вывода
+	static Byte* pLineStart = 0;
+
+	// В конце вызывается WordControl
 
 	switch(reason)
+	{
+		case BROWSE_CHAR: // Символ
 		{
-		case BROWSE_CHAR:
-			// Символ
 			// Установить язык
-			{
 			long lang = CED_GetCharFontLang(hObject);
 			if (lang != gLanguage)
 				SetLanguage(lang);
-			}
-
 			// Стиль шрифта
 			FontStyle(CED_GetCharFontAttribs(hObject));
 
 			r = CED_GetCharLayout(hObject);
 			// Записать символ
-                        if(r.left != -1 && hocrmode) {
-                            sprintf(buf, "<span title=\"bbox %d %d %d %d\">", r.left,
-                            r.top, r.right, r.bottom);
-                            PUT_STRING(buf);
-                        }
-
-                        ONE_CHAR(hObject);
-                        if(r.left != -1 && hocrmode)
-                            PUT_STRING("</span>");
-
+            if(r.left != -1 && hocrmode) 
+			{
+                sprintf(buf, "<span title=\"bbox %d %d %d %d\">"
+					, r.left, r.top, r.right, r.bottom);
+                PUT_STRING(buf);
+				if (0 == isInLine)
+				// начнем определение границ строки
+				{
+					rcLine = r;
+				}
+				else
+				{
+					rcLine.left = min(rcLine.left, r.left);
+					rcLine.top = min(rcLine.top, r.top);
+					rcLine.right = max(rcLine.right, r.right);
+					rcLine.bottom = max(rcLine.bottom, r.bottom);
+				}
+            }
+            ONE_CHAR(hObject);
+            if(r.left != -1 && hocrmode)
+                PUT_STRING("</span>");
+
+			break;
+		}
+		case BROWSE_LINE_START:
+			// Начало строки текста
+			pLineStart = gMemCur;
 			break;
 
 		case BROWSE_LINE_END:
 			// Конец строки текста
+			writeHocrLine(pLineStart, rcLine, iLine++);				
+			isInLine = false;
 			if ( gPreserveLineBreaks || gEdLineHardBreak )
+			{
 				PUT_STRING("<br>");
+			}
+			NEW_LINE;
 			break;
 
 		case BROWSE_PARAGRAPH_START:
@@ -160,22 +243,47 @@
 			// Конец абзаца
 			FontStyle(0);
 			PUT_STRING("</p>");
+			NEW_LINE;
 			break;
 
 		case BROWSE_PAGE_START:
 			// Start of page.
 			FontStyle(0);
-			PUT_STRING("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"   \"http://www.w3.org/TR/html4/loose.dtd\">\n");
-			PUT_STRING("<html><head><title></title>");
-			if (gActiveCode==ROUT_CODE_UTF8) 
-				 PUT_STRING("<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" >");
-			PUT_STRING("</head><body>");
-
+			{
+				ostringstream outStrm;
+				outStrm << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 "
+					       "Transitional//EN\""
+						   " \"http://www.w3.org/TR/html4/loose.dtd\">" << endl;
+				outStrm << "<html><head><title></title>" << endl;
+				if (gActiveCode==ROUT_CODE_UTF8) 
+				{
+					outStrm << "<meta http-equiv=\"Content-Type\""
+						       " content=\"text/html;charset=utf-8\" >" << endl;
+				}
+				outStrm << "<meta name='ocr-system' content='openocr'>" << endl;
+				outStrm << "</head>" << endl << "<body>";
+				strm2buf(outStrm);
+			}
+			{
+				ostringstream outStrm;
+				EDSIZE sizeImage(CED_GetPageImageSize(hObject));
+				const char* pImageName = CED_GetPageImageName(hObject);
+				assert(pImageName);
+				//пример <div class='ocr_page' title='image "page-000.pbm"; bbox 0 0 4306 6064'>
+				outStrm << "<div class='ocr_page' id='page_" << iPage << "' ";
+				outStrm << "title='image \"" << pImageName << "\"; bbox 0 0 "
+					<< sizeImage.cx << " " << sizeImage.cy << "'" << endl;
+				strm2buf(outStrm);
+				++iPage;
+			}
 			break;
 
 		case BROWSE_PAGE_END:
 			// Конец страницы
+			PUT_STRING("</div>");
+			// Конец документа
 			PUT_STRING("</body></html>");
+			iLine = 1;
 			break;
 
 		case BROWSE_TABLE_START:

