public void RenderText(TextRenderInfo renderInfo) { List<TextRenderInfo> subs = renderInfo.GetCharacterRenderInfos(); TextRenderInfo previousCharInfo = subs[0]; for (int i = 1; i < subs.Count; i++) { TextRenderInfo charInfo = subs[i]; Vector previousEndPoint = previousCharInfo.GetBaseline().GetEndPoint(); Vector currentStartPoint = charInfo.GetBaseline().GetStartPoint(); AssertVectorsEqual(previousEndPoint, currentStartPoint, charInfo.GetText()); previousCharInfo = charInfo; } }
//Automatically called for each chunk of text in the PDF public override void RenderText(TextRenderInfo renderInfo) { base.RenderText(renderInfo); //See if the current chunk contains the text var startPosition = System.Globalization.CultureInfo.CurrentCulture.CompareInfo.IndexOf( renderInfo.GetText(), this.TextToSearchFor, this.CompareOptions); //If not found bail if (startPosition < 0) { return; } if (renderInfo.PdfString.ToString() != this.TextToSearchFor) { return; } //Grab the individual characters var chars = renderInfo.GetCharacterRenderInfos().Skip(startPosition).Take(this.TextToSearchFor.Length).ToList(); //Grab the first and last character var firstChar = chars.First(); var lastChar = chars.Last(); //Get the bounding box for the chunk of text var bottomLeft = firstChar.GetDescentLine().GetStartPoint(); var topRight = lastChar.GetAscentLine().GetEndPoint(); //Create a rectangle from it var rect = new iTextSharp.text.Rectangle( bottomLeft[Vector.I1], bottomLeft[Vector.I2], topRight[Vector.I1], topRight[Vector.I2] ); //Add this to our main collection this.MyPoints.Add(new RectAndText(rect, this.TextToSearchFor)); }
public virtual void RenderText(TextRenderInfo renderInfo) { if (renderInfo.PdfString.ToUnicodeString().Length == 0) { return; } // if true, than clipping path was completely cleaned if (newClippingPath.IsEmpty()) { LineSegment baseline = renderInfo.GetUnscaledBaseline(); chunks.Add(new PdfCleanUpContentChunk.Text(renderInfo.PdfString, baseline.GetStartPoint(), baseline.GetEndPoint(), false, strNumber)); } else { foreach (TextRenderInfo ri in renderInfo.GetCharacterRenderInfos()) { bool isAllowed = filter.AllowText(ri); LineSegment baseline = ri.GetUnscaledBaseline(); chunks.Add(new PdfCleanUpContentChunk.Text(ri.PdfString, baseline.GetStartPoint(), baseline.GetEndPoint(), isAllowed, strNumber)); } } ++strNumber; }
public override void RenderText(TextRenderInfo renderInfo) { foreach (TextRenderInfo tri in renderInfo.GetCharacterRenderInfos()) base.RenderText(tri); }
public virtual void RenderText(TextRenderInfo renderInfo) { if (renderInfo.PdfString.ToUnicodeString().Length == 0) { return; } foreach (TextRenderInfo ri in renderInfo.GetCharacterRenderInfos()) { bool isAllowed = filter.AllowText(ri); LineSegment baseline = ri.GetUnscaledBaseline(); chunks.Add(new PdfCleanUpContentChunk.Text(ri.PdfString, baseline.GetStartPoint(), baseline.GetEndPoint(), isAllowed, strNumber)); } ++strNumber; }