update XYLeaf with word separator

This commit is contained in:
BobLd
2020-05-23 20:04:52 +01:00
committed by Eliot Jones
parent 79b78f486a
commit 5362a335f5

View File

@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UglyToad.PdfPig.DocumentLayoutAnalysis.ReadingOrderDetector;
using UglyToad.PdfPig.Geometry;
/// <summary>
@@ -38,20 +39,19 @@
/// <summary>
/// Gets the lines of the leaf.
/// </summary>
public IReadOnlyList<TextLine> GetLines()
public IReadOnlyList<TextLine> 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();
}
/// <summary>
/// Create a new <see cref="XYLeaf"/>.
/// </summary>
/// <param name="words">The words contained in the leaf.</param>
public XYLeaf(params Word[] words) : this(words == null ? null : words.ToList())
{
}
public XYLeaf(params Word[] words) : this(words?.ToList())
{ }
/// <summary>
/// Create a new <see cref="XYLeaf"/>.
@@ -73,4 +73,4 @@
Words = words.ToArray();
}
}
}
}