User Guide > How to Work with... > Recognition > Recognition > The Recognition Process > Recognize a Multi-Page Document |
In this example, the application specifies the output format (Converters.Text.Word2000) for the final output document (MULTIPAG.DOC) with the Format property. Then the multi-page result of the recognition stored in the recognition data file is converted into the requested format with the ImGearRecOutputManager.WriteDocument Method call.
C# |
Copy Code |
---|---|
ImGearRecDocument document = ImGearRecDocument.Create(null); using (FileStream content = new FileStream("MULTIPAG.TIF", FileMode.Open)) { int numPages = ImGearFileFormats.GetPageCount(content, ImGearFormats.UNKNOWN); for (int i = 0; i < numPages; i++) { ImGearPage igPage = ImGearFileFormats.LoadPage(content, i); ImGearRecPage igRecPage = igRecognition.ImportPage((ImGearRasterPage)igPage); igRecPage.Image.Preprocess(); igRecPage.Recognize(); document.InsertPage(igRecPage, -1); } } igRecognition.OutputManager.CodePage = "Windows ANSI"; igRecognition.OutputManager.Level = ImGearRecOutputLevel.AUTO; igRecognition.OutputManager.Format = "Converters.Text.Word2000"; igRecognition.OutputManager.WriteDocument(document, "MULTIPAG.DOC"); document.Dispose(); |
VB .NET |
Copy Code |
---|---|
Dim document As ImGearRecDocument = ImGearRecDocument.Create(Nothing) Using content As New FileStream("MULTIPAG.TIF", FileMode.Open) Dim numPages As Integer = ImGearFileFormats.GetPageCount(content, ImGearFormats.UNKNOWN) Dim i As Integer = 0 While i < numPages Dim igPage As ImGearPage = ImGearFileFormats.LoadPage(content, i) Dim igRecPage As ImGearRecPage = igRecognition.ImportPage(DirectCast(igPage, ImGearRasterPage)) igRecPage.Image.Preprocess() igRecPage.Recognize() document.InsertPage(igRecPage, -1) System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1) End While End Using igRecognition.OutputManager.CodePage = "Windows ANSI" igRecognition.OutputManager.Level = ImGearRecOutputLevel.AUTO igRecognition.OutputManager.Format = "Converters.Text.Word2000" igRecognition.OutputManager.WriteDocument(document, "MULTIPAG.DOC") document.Dispose() |