예제 #1
0
        /// <summary>
        /// This is the main method for extraction
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        public TableResult GetTableContent(Document document)
        {
            TableResult result = new TableResult(this);

            // generate lines..
            ArrayList lines = document.GenerateLines(DocumentArea);

            result.Init(lines);

            for (int i = 0; i < lines.Count; i++)
            {
                Line   line = (Line)lines[i];
                string s    = line.Content;
                // iterate through all contained words and decide for each one, where it belongs to..
                for (int j = 0; j < line.Words.Count; j++)
                {
                    Word          word   = (Word)line.Words[j];
                    ColumnRequest column = GetContainingColumn(word.Bounds);
                    if (column != null)
                    {
                        ColumnResult columnResult = result.GetColumnResult(line, column);
                        if (columnResult != null)
                        {
                            // add word to the corresponding result element
                            columnResult.Words.Add(word);
                        }
                    }
                }
            }
            return(result);
        }
예제 #2
0
 public ColumnResult GetColumnResult(ColumnRequest column)
 {
     for (int i = 0; i < _ColumnResults.Count; i++)
     {
         ColumnResult result = (ColumnResult)_ColumnResults[i];
         if (result.ColumnRequest == column)
         {
             return(result);
         }
     }
     return(null);
 }
예제 #3
0
 public ColumnResult GetColumnResult(Line line, ColumnRequest column)
 {
     for (int i = 0; i < _lineResults.Count; i++)
     {
         LineResult lineResult = (LineResult)_lineResults[i];
         if (lineResult.LineReference == line)
         {
             return(lineResult.GetColumnResult(column));
         }
     }
     return(null);
 }
예제 #4
0
        /// <summary>
        /// Evaluates the Columns X Positon refering to the current request area.
        /// As long as we dont use caching, we have to calculate it every time.
        /// </summary>
        /// <returns></returns>
        private float GetColumnOffset(int index)
        {
            if (index > _ColumnRequests.Count)
            {
                throw new Exception("Wrong parameter");
            }
            float offset = 0;

            for (int i = 0; i < index; i++)
            {
                ColumnRequest colRequest = (ColumnRequest)_ColumnRequests[i];
                offset += colRequest.Width;
            }
            return(offset);
        }