diff --git a/src/UglyToad.PdfPig.DocumentLayoutAnalysis/PageSegmenter/XYLeaf.cs b/src/UglyToad.PdfPig.DocumentLayoutAnalysis/PageSegmenter/XYLeaf.cs index 6c120233..2bfb299f 100644 --- a/src/UglyToad.PdfPig.DocumentLayoutAnalysis/PageSegmenter/XYLeaf.cs +++ b/src/UglyToad.PdfPig.DocumentLayoutAnalysis/PageSegmenter/XYLeaf.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; + using UglyToad.PdfPig.DocumentLayoutAnalysis.ReadingOrderDetector; using UglyToad.PdfPig.Geometry; /// @@ -38,20 +39,19 @@ /// /// Gets the lines of the leaf. /// - public IReadOnlyList GetLines() + public IReadOnlyList GetLines(string wordSeparator) { - return Words.GroupBy(x => x.BoundingBox.Bottom).OrderByDescending(x => x.Key) - .Select(x => new TextLine(x.ToList())).ToArray(); + return Words.GroupBy(x => x.BoundingBox.Bottom) + .Select(x => new TextLine(x.OrderByReadingOrder(), wordSeparator)) + .OrderByReadingOrder(); } /// /// Create a new . /// /// The words contained in the leaf. - public XYLeaf(params Word[] words) : this(words == null ? null : words.ToList()) - { - - } + public XYLeaf(params Word[] words) : this(words?.ToList()) + { } /// /// Create a new . @@ -73,4 +73,4 @@ Words = words.ToArray(); } } -} +} \ No newline at end of file