private static string ParseFile(ITextExtractor textExtractor, string filename)
        {
            // Images: https://www.google.se/search?q=tiff+ifilter&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=fflb#hl=sv&client=firefox-a&hs=Cis&tbo=d&rls=org.mozilla:en-US%3Aofficial&channel=fflb&sclient=psy-ab&q=image+ifilter&oq=image+ifilter&gs_l=serp.3..0i13l4.4693.4693.1.4936.1.1.0.0.0.0.55.55.1.1.0...0.0...1c.1.k9PU0a3S1m4&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.&bvm=bv.1355534169,d.bGE&fp=71792659602ba5ba&bpcl=40096503&biw=1680&bih=919
            // http://technet.microsoft.com/sv-se/library/dd834685.aspx
            // http://technet.microsoft.com/en-us/library/dd744701%28v=ws.10%29.aspx

            // var filename = Environment.CurrentDirectory + "\\test.pdf";
            // x64, working: http://www.adobe.com/support/downloads/thankyou.jsp?ftpID=4025&fileID=3941
            // http://www.adobe.com/support/downloads/detail.jsp?ftpID=2611
            // http://www.foxitsoftware.com/products/ifilter/

            // http://www.microsoft.com/en-us/download/details.aspx?id=3988
            // var filename = Environment.CurrentDirectory + "\\test.docx";    // http://www.microsoft.com/en-us/download/details.aspx?id=20109
            // http://www.microsoft.com/en-us/download/details.aspx?id=17062
            // var filename = Environment.CurrentDirectory + "\\test.txt";
            /*
            try
            {
                using (var stream = File.OpenRead(filename))
                {
                    return textExtractor.GetText(stream);
                }
            }
            catch(Exception exc)
            {
                Console.WriteLine("Exception was thrown while reading '" + filename + "'");
                Console.WriteLine("Exception: " + exc.Message);
                return "";
            }
            */
            return textExtractor.GetText(filename);
        }
Beispiel #2
0
        private async Task <string> TryRecognizeText(DigitDetectionOptions options, System.Drawing.Bitmap bitmap)
        {
            textExtractor.Initialize(options ?? DigitDetectionOptions.Default, continuityManager.GetCurrentNumber());

            int tries = 10;

            while (tries-- > 0)
            {
                try
                {
                    return(textExtractor.GetText(bitmap));
                }
                catch (InvalidOperationException)
                {
                    await Task.Delay(250);
                }
            }

            return(null);
        }
        public override string ToString()
        {
            int    count  = 1;
            string result = String.Empty;

            foreach (object o in this)
            {
                result += m_TextExtractor.GetText(o);

                if (count < (Count - 1))
                {
                    result += m_Delimiter;
                }
                else if (count < Count)
                {
                    result += FinalDelimiter;
                }

                ++count;
            }

            return(result);
        }