コード例 #1
0
        protected override void Execute(CodeActivityContext context)
        {
            ExtractorDocumentType documentType   = ExtractorDocumentType.Get(context);
            ResultsDocumentBounds documentBounds = DocumentBounds.Get(context);
            string   text         = DocumentText.Get(context);
            Document document     = DocumentObjectModel.Get(context);
            string   documentPath = DocumentPath.Get(context);

            ExtractorResult.Set(context, ComputeResult(documentType, documentBounds, text, document, documentPath));
        }
コード例 #2
0
        private ExtractorResult ComputeResult(ExtractorDocumentType documentType, ResultsDocumentBounds documentBounds, string text, Document document, string documentPath)
        {
            var extractorResult   = new ExtractorResult();
            var resultsDataPoints = new List <ResultsDataPoint>();

            // example of reporting a value with derived parts
            Field firstDateField = documentType.Fields.FirstOrDefault(f => f.Type == FieldType.Date);

            if (firstDateField != null)
            {
                // if any field is of type Date return first word on first page as reference and report Jan 1st 2002 as value
                resultsDataPoints.Add(CreateDateFieldDataPoint(firstDateField, document));
            }

            // example of report a value with no textual reference (only visual reference)
            Field firstBooleanField = documentType.Fields.FirstOrDefault(f => f.Type == FieldType.Boolean);

            if (firstBooleanField != null)
            {
                // if any field is of type Boolean return "true" with a visual reference from pixel position (50, 100) and width 200 and height 300.
                resultsDataPoints.Add(CreateBooleanFieldDataPoint(firstBooleanField, document));
            }

            // example of table value
            Field firstTableField = documentType.Fields.FirstOrDefault(f => f.Type == FieldType.Table);

            if (firstTableField != null)
            {
                // if any field is of type Table return a table with headers referencing the first N words and 2 rows referencing the next N * 2 words.
                // N will be the number of columns in the table field.
                resultsDataPoints.Add(CreateTableFieldDataPoint(firstTableField, document));
            }

            extractorResult.DataPoints = resultsDataPoints.ToArray();
            return(extractorResult);
        }