|
Hi
Actully have you seen Ebook functionality in google,i want to search according to that,first i have to search the document having that word and hightlight that word .I can Scan multple docuement page and able to OCR also on that ans storing after ocr as .txt,doc and .rdf,so issue is that in the searched document there can be multiple page and how i can provide highlighting facility and then showing that document,i can try to OCR each page and after recognizing i want the image to be displayed on RoasterTumnailBrowser ,having hightlight on page and continued for other pages.
Attaching code on which i am working
Dim FileName As String = "C:\Documents and Settings\priyanka\Desktop\manoj\MultiplePageScan1\All.tif"
RasterCodecs.Startup()
Dim codecs As RasterCodecs
'Dim image As RasterImage
codecs = New RasterCodecs()
RasterImageViewer1.Image = codecs.Load(FileName)
'image = codecs.Load("E:\My Document\icon\ph\photo\scan0003.bmp")
'image = codecs.Load("C:\Documents and Settings\priyanka\Desktop\manoj\MultiplePageScan1\All.tif")
' Unlock support for the OCR engine
RasterSupport.Unlock(RasterSupportType.Ocr, "TestKey")
rasterDoc.RecognitionDataFileName = "c:\testrdf.rdf"
' Delete the RDF if it already exists
If File.Exists(rasterDoc.RecognitionDataFileName) Then
File.Delete(rasterDoc.RecognitionDataFileName)
Else
' Do nothing
End If
Dim k As Integer
Dim info As CodecsImageInfo = codecs.GetInformation(FileName, True)
For k = 1 To info.TotalPages
Dim image As RasterImage = codecs.Load(FileName, 0, CodecsLoadByteOrder.BgrOrGray, k, k)
rasterDoc.SpellLanguageId = RasterDocumentLanguage.English
rasterDoc.EnableSubsystem = True
rasterDoc.EnableCorrection = True
RasterImageViewer1.Image = codecs.Load(FileName)
rasterDoc.AddPage(image, 0)
annContainerObj = New AnnContainer
annContainerObj.Bounds = New AnnRectangle(0, 0, RasterImageViewer1.ImageSize.Width, RasterImageViewer1.ImageSize.Height, AnnUnit.Pixel)
annContainerObj.Name = "Container"
annContainerObj.Visible = True
annContainerObj.UnitConverter = New AnnUnitConverter(96, 96)
rasterDoc.AddPage(image, 0)
' Specifies the name of the file that will be used in the recognition.
rasterDoc.Recognize(0, 1, Nothing)
'Dim recogWords As IList(Of RasterDocumentRecognizedWords) = rasterDocument.GetRecognizedWords(0)
Dim recogWords As IList = rasterDoc.GetRecognizedWords(0)
Dim i As Integer
Dim count As Integer
count = 0
' Get word to locate
Dim word_to_find As String = InputBox("Enter the word you would like to find and highlight", "Enter Word")
' Loop through all of the recognized words, get the coordinates
' and place an annotation there
For i = 0 To recogWords.Count - 1
If recogWords(i).Word = word_to_find Then
count = count + 1
End If
Next
If count = 0 Then
MessageBox.Show(word_to_find & " was not found")
Else
MessageBox.Show(word_to_find & " was found " & count.ToString & " times")
Dim highlights(count) As AnnHiliteObject
For i = 0 To count
highlights(i) = New AnnHiliteObject
Next
count = 0
'Dim image1 As RasterImage
For i = 0 To recogWords.Count - 1
If recogWords(i).Word = word_to_find Then
highlights(count).Bounds = New AnnRectangle(recogWords(i).WordArea.Left, recogWords(i).WordArea.Top, recogWords(i).WordArea.Width, recogWords(i).WordArea.Height, AnnUnit.Pixel)
highlights(count).HiliteColor = Color.Yellow
annContainerObj.Objects.Add(highlights(count))
RasterImageViewer1.Refresh()
count = count + 1
End If
Next
End If
Next
Dim image1 As RasterImage = RasterImageViewer1.Image
Dim imageFileName As String = "Page" & k & ""
Dim item As RasterImageListItem = New RasterImageListItem(image1, k, imageFileName)
'Dim item As RasterImageListItem = New RasterImageListItem(image1, k, imageFileName)
'Select the first item
'If i = 0 Then
item.Selected = True
'End If
' Add the item to the image list
'Next
RasterThumbnailBrowser1.Items.Add(item)
|