Visual Basic
C#
Managed Extensions for C++
C++/CLI
Parameters
- pages
- Array of ImGearRecPage objects with the valid recognition data to be saved.
- file
- File to save recognition data to.
Use DirectTextFormat to get or set the output format. If file parameter specifies an existing file name, the text outputs are appended.
C# | Copy Code |
---|---|
using (FileStream content = new FileStream("MULTIPAG.TIF", FileMode.Open)) { int numPages = ImGearFileFormats.GetPageCount(content, ImGearFormats.UNKNOWN); int i; ImGearRecPage[] pages = new ImGearRecPage[numPages]; for (i = 0; i < numPages; i++) { ImGearPage igPage = ImGearFileFormats.LoadPage(content, i); pages[i] = igRecognition.ImportPage((ImGearRasterPage)igPage); pages[i].Image.Preprocess(); pages[i].Recognize(); } igRecognition.OutputManager.CodePage = "Windows ANSI"; igRecognition.OutputManager.DirectTextFormat = ImGearRecDirectTextFormat.FormattedText; if(File.Exists("MULTIPAG.TXT")) { File.Delete("MULTIPAG.TXT"); } igRecognition.OutputManager.WriteDirectText(pages, "MULTIPAG.TXT"); for(i = 0; i < pages.Length; i ++) { pages[i].Dispose(); } } |
Visual Basic | Copy Code |
---|---|
Using content As New FileStream("MULTIPAG.TIF", FileMode.Open) Dim numPages As Integer = ImGearFileFormats.GetPageCount(content, ImGearFormats.UNKNOWN) Dim i As Integer Dim pages As ImGearRecPage() = New ImGearRecPage(numPages) {} i = 0 While i < numPages Dim igPage As ImGearPage = ImGearFileFormats.LoadPage(content, i) pages(i) = igRecognition.ImportPage(DirectCast(igPage, ImGearRasterPage)) pages(i).Image.Preprocess() pages(i).Recognize() System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1) End While igRecognition.OutputManager.CodePage = "Windows ANSI" igRecognition.OutputManager.DirectTextFormat = ImGearRecDirectTextFormat.FormattedText If File.Exists("MULTIPAG.TXT") Then File.Delete("MULTIPAG.TXT") End If igRecognition.OutputManager.WriteDirectText(pages, "MULTIPAG.TXT") i = 0 While i < pages.Length pages(i).Dispose() System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1) End While End Using |