public void CloseDocumentTest()
        {
            scripter.RunLine($@"ocrabbyy.processfile {SpecialChars.Variable}file language English result {SpecialChars.Variable}result1
                                ocrabbyy.processfile {SpecialChars.Variable}file language English result {SpecialChars.Variable}result2");
            int documentId = scripter.Variables.GetVariableValue <int>("result1");
            FineReaderDocument document = AbbyyManager.Instance.GetDocument(documentId);

            int document2Id = scripter.Variables.GetVariableValue <int>("result2");
            FineReaderDocument document2 = AbbyyManager.Instance.GetDocument(document2Id);

            scripter.Text = ($"ocrabbyy.close {document2Id}");
            scripter.Run();
            document.ExtractData();
            bool isDocumentClosed = false;

            try
            {
                document2.ExtractData();
            }
            catch
            {
                isDocumentClosed = true;
            }
            Assert.IsTrue(isDocumentClosed);

            scripter.Text = ($"ocrabbyy.close {documentId}");
            scripter.Run();
            isDocumentClosed = false;
            try
            {
                document.ExtractData();
            }
            catch
            {
                isDocumentClosed = true;
            }
            Assert.IsTrue(isDocumentClosed);
        }
Esempio n. 2
0
        public void Execute(Arguments arguments)
        {
            AbbyyManager       manager  = AbbyyManager.Instance;
            int                docID    = arguments.DocumentID == null ? manager.CurentDocumentCount : arguments.DocumentID.Value;
            FineReaderDocument document = manager.GetDocument(docID);

            document.ExtractData();
            List <FineReaderParagraph> paragraphs = document.Paragraphs;

            ListStructure paragraphsList = new ListStructure(new List <Structure>());

            foreach (FineReaderParagraph p in paragraphs)
            {
                paragraphsList.Value.Add(new TextStructure(p.Text));
            }

            Scripter.Variables.SetVariableValue(arguments.Result.Value, paragraphsList);
        }
Esempio n. 3
0
        public void Execute(Arguments arguments)
        {
            AbbyyManager manager = AbbyyManager.Instance;

            int docID = arguments.DocumentID == null ? manager.CurentDocumentCount : arguments.DocumentID.Value;

            FineReaderDocument document = manager.GetDocument(docID);

            document.ExtractData();

            ListStructure cellsText = new ListStructure(new List <Structure>());

            foreach (FineReaderCell c in document.Cells)
            {
                cellsText.Value.Add(new TextStructure(c.Text));
            }

            Scripter.Variables.SetVariableValue(arguments.Result.Value, cellsText);
        }
Esempio n. 4
0
        public void Execute(Arguments arguments)
        {
            AbbyyManager manager = AbbyyManager.Instance;

            FineReaderDocument.FilterFlags paramsFilter = FineReaderDocument.FilterFlags.none;

            string[] flagsString = arguments.Filter.Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string flag in flagsString)
            {
                FineReaderDocument.FilterFlags currentFlag = FineReaderDocument.FilterFlags.none;
                try
                {
                    currentFlag   = (FineReaderDocument.FilterFlags)Enum.Parse(typeof(FineReaderDocument.FilterFlags), flag.Trim(), true);
                    paramsFilter |= (FineReaderDocument.FilterFlags)Enum.Parse(typeof(FineReaderDocument.FilterFlags), flag.Trim(), true);
                }
                catch
                {
                    throw new ArgumentOutOfRangeException(nameof(arguments.Filter), currentFlag, $"{currentFlag} is not defined filter");
                }
            }

            int docID = arguments.DocumentID == null ? manager.CurentDocumentCount : arguments.DocumentID.Value;

            FineReaderDocument document = manager.GetDocument(docID);

            document.ExtractData();

            ListStructure filteredTexts = new ListStructure(new List <Structure>());

            foreach (string s in document.Filter(paramsFilter))
            {
                filteredTexts.Value.Add(new TextStructure(s));
            }

            Scripter.Variables.SetVariableValue(arguments.Result.Value, filteredTexts);
        }