From bb94348127fb3a7dacbfb893286c5038b8489fd0 Mon Sep 17 00:00:00 2001 From: BobLd Date: Sat, 23 May 2020 19:39:23 +0100 Subject: [PATCH] add text Separator in TextBlock and TextLine --- .../TextBlock.cs | 12 ++++++++++-- .../TextLine.cs | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/UglyToad.PdfPig.DocumentLayoutAnalysis/TextBlock.cs b/src/UglyToad.PdfPig.DocumentLayoutAnalysis/TextBlock.cs index 000e4603..a742d72f 100644 --- a/src/UglyToad.PdfPig.DocumentLayoutAnalysis/TextBlock.cs +++ b/src/UglyToad.PdfPig.DocumentLayoutAnalysis/TextBlock.cs @@ -11,6 +11,11 @@ /// public class TextBlock { + /// + /// The separator used between lines in the block. + /// + public readonly string Separator; + /// /// The text of the block. /// @@ -39,8 +44,9 @@ /// /// Create a new . /// - /// - public TextBlock(IReadOnlyList lines) + /// The words contained in the line, in the correct order. + /// The separator used between lines in the block. + public TextBlock(IReadOnlyList 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; diff --git a/src/UglyToad.PdfPig.DocumentLayoutAnalysis/TextLine.cs b/src/UglyToad.PdfPig.DocumentLayoutAnalysis/TextLine.cs index 22cd59f7..16855a9a 100644 --- a/src/UglyToad.PdfPig.DocumentLayoutAnalysis/TextLine.cs +++ b/src/UglyToad.PdfPig.DocumentLayoutAnalysis/TextLine.cs @@ -11,6 +11,11 @@ /// public class TextLine { + /// + /// The separator used between words in the line. + /// + public readonly string Separator; + /// /// The text of the line. /// @@ -34,8 +39,9 @@ /// /// Create a new . /// - /// The words contained in the line. - public TextLine(IReadOnlyList words) + /// The words contained in the line, in the correct order. + /// The separator used between words in the line. + public TextLine(IReadOnlyList 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));