mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-14 10:55:04 +08:00
add text Separator in TextBlock and TextLine
This commit is contained in:
@@ -11,6 +11,11 @@
|
||||
/// </summary>
|
||||
public class TextBlock
|
||||
{
|
||||
/// <summary>
|
||||
/// The separator used between lines in the block.
|
||||
/// </summary>
|
||||
public readonly string Separator;
|
||||
|
||||
/// <summary>
|
||||
/// The text of the block.
|
||||
/// </summary>
|
||||
@@ -39,8 +44,9 @@
|
||||
/// <summary>
|
||||
/// Create a new <see cref="TextBlock"/>.
|
||||
/// </summary>
|
||||
/// <param name="lines"></param>
|
||||
public TextBlock(IReadOnlyList<TextLine> lines)
|
||||
/// <param name="lines">The words contained in the line, in the correct order.</param>
|
||||
/// <param name="separator">The separator used between lines in the block.</param>
|
||||
public TextBlock(IReadOnlyList<TextLine> lines, string separator = "\n")
|
||||
{
|
||||
if (lines == null)
|
||||
{
|
||||
@@ -52,6 +58,8 @@
|
||||
throw new ArgumentException("Empty lines provided.", nameof(lines));
|
||||
}
|
||||
|
||||
Separator = separator;
|
||||
|
||||
ReadingOrder = -1;
|
||||
|
||||
TextLines = lines;
|
||||
|
@@ -11,6 +11,11 @@
|
||||
/// </summary>
|
||||
public class TextLine
|
||||
{
|
||||
/// <summary>
|
||||
/// The separator used between words in the line.
|
||||
/// </summary>
|
||||
public readonly string Separator;
|
||||
|
||||
/// <summary>
|
||||
/// The text of the line.
|
||||
/// </summary>
|
||||
@@ -34,8 +39,9 @@
|
||||
/// <summary>
|
||||
/// Create a new <see cref="TextLine"/>.
|
||||
/// </summary>
|
||||
/// <param name="words">The words contained in the line.</param>
|
||||
public TextLine(IReadOnlyList<Word> words)
|
||||
/// <param name="words">The words contained in the line, in the correct order.</param>
|
||||
/// <param name="separator">The separator used between words in the line.</param>
|
||||
public TextLine(IReadOnlyList<Word> words, string separator = " ")
|
||||
{
|
||||
if (words == null)
|
||||
{
|
||||
@@ -47,6 +53,8 @@
|
||||
throw new ArgumentException("Empty words provided.", nameof(words));
|
||||
}
|
||||
|
||||
Separator = separator;
|
||||
|
||||
Words = words;
|
||||
|
||||
Text = string.Join(" ", words.Where(s => !string.IsNullOrWhiteSpace(s.Text)).Select(x => x.Text));
|
||||
|
Reference in New Issue
Block a user