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