diff --git a/itext/itext.kernel/itext/kernel/pdf/canvas/parser/listener/LocationTextExtractionStrategy.cs b/itext/itext.kernel/itext/kernel/pdf/canvas/parser/listener/LocationTextExtractionStrategy.cs index 9ce17a3f4..8535c4f40 100644 --- a/itext/itext.kernel/itext/kernel/pdf/canvas/parser/listener/LocationTextExtractionStrategy.cs +++ b/itext/itext.kernel/itext/kernel/pdf/canvas/parser/listener/LocationTextExtractionStrategy.cs @@ -45,6 +45,9 @@ public class LocationTextExtractionStrategy : ITextExtractionStrategy { private TextRenderInfo lastTextRenderInfo; + private string elementSeparator = ""; + private string newLine = "\n"; + /// Creates a new text extraction renderer. public LocationTextExtractionStrategy() : this(new LocationTextExtractionStrategy.ITextChunkLocationStrategyImpl()) { @@ -60,6 +63,16 @@ public LocationTextExtractionStrategy(LocationTextExtractionStrategy.ITextChunkL tclStrat = strat; } + /// + /// Sets the string values used to separate elements and lines when formatting output. + /// + /// The string to use as a separator between elements. Cannot be null. + /// The string to use to represent a new line. Cannot be null. + public void SetSeparators(string elementSeparator, string newLine) { + this.elementSeparator = elementSeparator; + this.newLine = newLine; + } + /// /// Changes the behavior of text extraction so that if the parameter is set to /// @@ -166,12 +179,12 @@ public virtual String GetResultantText() { // we only insert a blank space if the trailing character of the previous string wasn't a space, and the leading character of the current string isn't a space if (IsChunkAtWordBoundary(chunk, lastChunk) && !StartsWithSpace(chunk.text) && !EndsWithSpace(lastChunk.text )) { - sb.Append(' '); + sb.Append(elementSeparator); } sb.Append(chunk.text); } else { - sb.Append('\n'); + sb.Append(newLine); sb.Append(chunk.text); } }