private static PdfRectangle getIntersectionBounds(PdfTextData data, string text, int startIndex, int length) { if (startIndex == 0 && text.Length == length) { return(data.Bounds); } IEnumerable <PdfTextData> characters = data.GetCharacters(); if (!containsLtrCharactersOnly(data, text)) { // Process right-to-left chunks in the reverse order. // // Note that this approach might not work for chunks // containing both left-to-right and right-to-left characters. characters = characters.Reverse(); } IEnumerable <PdfRectangle> charBounds = characters .Skip(startIndex) .Take(length) .Select(c => c.Bounds); PdfRectangle union = charBounds.First(); foreach (var b in charBounds.Skip(1)) { union = PdfRectangle.Union(b, union); } return(union); }
private static PdfRectangle getIntersectionBounds(PdfTextData data, int startIndex, int length) { string text = data.Text; if (startIndex == 0 && text.Length == length) { return(data.Bounds); } IEnumerable <PdfRectangle> charBounds = data.GetCharacters() .Skip(startIndex) .Take(length) .Select(c => c.Bounds); PdfRectangle union = charBounds.First(); foreach (var b in charBounds.Skip(1)) { union = PdfRectangle.Union(b, union); } return(union); }