mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-19 02:37:56 +08:00
update XYLeaf with word separator
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user