public virtual string GetResultantText()
        {
            if (LocationTextExtractionStrategy2.DUMP_STATE)
            {
                this.DumpState();
            }
            IList <LocationTextExtractionStrategy2.TextChunk> list = new List <LocationTextExtractionStrategy2.TextChunk>(this.locationalResult);

            this.SortWithMarks(list);
            StringBuilder stringBuilder = new StringBuilder();

            LocationTextExtractionStrategy2.TextChunk textChunk = null;
            foreach (LocationTextExtractionStrategy2.TextChunk current in list)
            {
                if (textChunk == null)
                {
                    stringBuilder.Append(current.text);
                }
                else
                {
                    if (current.SameLine(textChunk))
                    {
                        if (this.IsChunkAtWordBoundary(current, textChunk) && !this.StartsWithSpace(current.text) && !this.EndsWithSpace(textChunk.text))
                        {
                            stringBuilder.Append(";;");
                        }
                        stringBuilder.Append(current.text);
                    }
                    else
                    {
                        stringBuilder.Append('\n');
                        stringBuilder.Append(current.text);
                    }
                }
                textChunk = current;
            }
            return(stringBuilder.ToString());
        }
 public virtual void EventOccurred(IEventData data, EventType type)
 {
     if (type.Equals(EventType.RENDER_TEXT))
     {
         TextRenderInfo textRenderInfo = (TextRenderInfo)data;
         LineSegment    lineSegment    = textRenderInfo.GetBaseline();
         if (textRenderInfo.GetRise() != 0f)
         {
             Matrix m = new Matrix(0f, -textRenderInfo.GetRise());
             lineSegment = lineSegment.TransformBy(m);
         }
         if (this.useActualText)
         {
             CanvasTag canvasTag = (this.lastTextRenderInfo != null) ? this.FindLastTagWithActualText(this.lastTextRenderInfo.GetCanvasTagHierarchy()) : null;
             if (canvasTag != null && canvasTag == this.FindLastTagWithActualText(textRenderInfo.GetCanvasTagHierarchy()))
             {
                 LocationTextExtractionStrategy2.TextChunk textChunk = this.locationalResult[this.locationalResult.Count - 1];
                 Vector startPoint = new Vector(Math.Min(textChunk.GetLocation().GetStartLocation().Get(0), lineSegment.GetStartPoint().Get(0)), Math.Min(textChunk.GetLocation().GetStartLocation().Get(1), lineSegment.GetStartPoint().Get(1)), Math.Min(textChunk.GetLocation().GetStartLocation().Get(2), lineSegment.GetStartPoint().Get(2)));
                 Vector endPoint   = new Vector(Math.Max(textChunk.GetLocation().GetEndLocation().Get(0), lineSegment.GetEndPoint().Get(0)), Math.Max(textChunk.GetLocation().GetEndLocation().Get(1), lineSegment.GetEndPoint().Get(1)), Math.Max(textChunk.GetLocation().GetEndLocation().Get(2), lineSegment.GetEndPoint().Get(2)));
                 LocationTextExtractionStrategy2.TextChunk value = new LocationTextExtractionStrategy2.TextChunk(textChunk.GetText(), this.tclStrat.CreateLocation(textRenderInfo, new LineSegment(startPoint, endPoint)));
                 this.locationalResult[this.locationalResult.Count - 1] = value;
             }
             else
             {
                 string actualText = textRenderInfo.GetActualText();
                 LocationTextExtractionStrategy2.TextChunk item = new LocationTextExtractionStrategy2.TextChunk((actualText != null) ? actualText : textRenderInfo.GetText(), this.tclStrat.CreateLocation(textRenderInfo, lineSegment));
                 this.locationalResult.Add(item);
             }
         }
         else
         {
             LocationTextExtractionStrategy2.TextChunk item2 = new LocationTextExtractionStrategy2.TextChunk(textRenderInfo.GetText(), this.tclStrat.CreateLocation(textRenderInfo, lineSegment));
             this.locationalResult.Add(item2);
         }
         this.lastTextRenderInfo = textRenderInfo;
     }
 }
 /// <summary>Determines if a space character should be inserted between a previous chunk and the current chunk.
 ///     </summary>
 /// <remarks>
 /// Determines if a space character should be inserted between a previous chunk and the current chunk.
 /// This method is exposed as a callback so subclasses can fine time the algorithm for determining whether a space should be inserted or not.
 /// By default, this method will insert a space if the there is a gap of more than half the font space character width between the end of the
 /// previous chunk and the beginning of the current chunk.  It will also indicate that a space is needed if the starting point of the new chunk
 /// appears *before* the end of the previous chunk (i.e. overlapping text).
 /// </remarks>
 /// <param name="chunk">the new chunk being evaluated</param>
 /// <param name="previousChunk">the chunk that appeared immediately before the current chunk</param>
 /// <returns>true if the two chunks represent different words (i.e. should have a space between them).  False otherwise.
 ///     </returns>
 protected internal virtual bool IsChunkAtWordBoundary(LocationTextExtractionStrategy2.TextChunk chunk, LocationTextExtractionStrategy2.TextChunk previousChunk)
 {
     return(chunk.GetLocation().IsAtWordBoundary(previousChunk.GetLocation()));
 }