/// <summary>
        /// Merge two line to one line.
        /// </summary>
        /// <param name="mergeLines">Line to be merged.</param>
        void  MergeLines(FormLineList mergeLines, FormLineList sameLevelLines)
        {
            if (mergeLines == null || mergeLines.Count < 2)
            {
                return;
            }

            FormLine firstLine    = mergeLines[0];
            bool     isHorizontal = firstLine.IsTransverseLine;

            if (isHorizontal)
            {
                List <double> xValues = mergeLines.Select(line => line.StartPoint.x).
                                        Concat(mergeLines.Select(line => line.EndPoint.x)).ToList();
                firstLine.StartPoint.x = xValues.Min();
                firstLine.EndPoint.x   = xValues.Max();
            }
            else
            {
                List <double> yValues = mergeLines.Select(line => line.StartPoint.y).
                                        Concat(mergeLines.Select(line => line.EndPoint.y)).ToList();
                firstLine.StartPoint.y = yValues.Min();
                firstLine.EndPoint.y   = yValues.Max();
            }
            for (int i = 1; i < mergeLines.Count; i++)
            {
                sameLevelLines.Remove(mergeLines[i]);
            }
        }
        /// <summary>
        /// Remove short lines from line dictionary.
        /// </summary>
        /// <param name="diclines">Line dictionary</param>
        void RemoveTooShortAndTooLongLines(Page page, SortedDictionary <double, FormLineList> diclines, bool isHorizontial, Rect posRect)
        {
            double[] pageSize = PdfTronHelper.GetPageSize(page);

            double maxLength = isHorizontial ? pageSize[0] : pageSize[1];

            diclines.Where(pair => pair.Value.Exists(line => Math.Abs(line.Length - maxLength) < 3))
            .Select(pair => pair.Key).ToList()
            .ForEach(key => diclines.Remove(key));
            FormLineList _lines = new FormLineList(diclines.SelectMany(pair => pair.Value).ToList());

            if (_lines.Count > 1)
            {
                if (isHorizontial)
                {
                    double[] textLeftRightXValue = pdfTronHelper.GetLeftRightTextBounds(page);
                    maxLength = (textLeftRightXValue[1] - textLeftRightXValue[0]);
                    diclines.Where(x => x.Value.Sum(line => line.Length) < maxLength * 0.5
                                   ).Select(x => x.Key).ToList().ForEach(key => diclines.Remove(key));
                    foreach (double key in diclines.Keys.ToArray())
                    {
                        FormLineList lines = diclines[key];
                        if (lines.Count < 2)
                        {
                            continue;
                        }
                        double   _maxLength    = lines.Max(line => line.Length);
                        FormLine maxLengthLine = lines.Find(line => line.Length == _maxLength);
                        lines.Where(line => line.Length < (_maxLength * 0.7)).ToList().ForEach(line => lines.Remove(line));
                    }
                    FormLineList templines = new FormLineList(diclines.SelectMany(pair => pair.Value).ToList());

                    if (templines.Count > 1)
                    {
                        maxLength = templines.Select(line => line.Length).Max();
                        double scale     = 0.4;
                        double minLength = maxLength * scale;
                        IEnumerable <double> shortLineKeys = diclines.Where(
                            x => x.Value.Sum(line => line.Length) < minLength
                            ).Select(x => x.Key);
                        shortLineKeys.ToList().ForEach(key => diclines.Remove(key));
                    }
                }
                else
                {
                    maxLength = posRect.Height();
                    if (posRect.Height() < 300)
                    {
                        maxLength = _lines.Select(line => line.Length).Max();
                    }
                    double minLength = maxLength * 0.4;

                    if (minLength < 9)
                    {
                        minLength = 9;
                    }

                    IEnumerable <double> shortLineKeys = diclines.Where(
                        x => x.Value.Sum(line => line.Length) < minLength
                        ).Select(x => x.Key);
                    shortLineKeys.ToList().ForEach(key => diclines.Remove(key));
                }
            }
            else
            {
                diclines.Clear();
            }
        }