/// <summary> /// Represents a chunk of text, it's orientation, and location relative to the orientation vector /// </summary> /// <param name="txt"></param> /// <param name="startLoc"></param> /// <param name="endLoc"></param> /// <param name="charSpaceWidth"></param> public TextChunkEx(string txt, iTextSharp.text.pdf.parser.Vector startLoc, iTextSharp.text.pdf.parser.Vector endLoc, float charSpaceWidth, iTextSharp.text.pdf.parser.LineSegment ascentLine, iTextSharp.text.pdf.parser.LineSegment decentLine) { m_text = txt; m_startLocation = startLoc; m_endLocation = endLoc; m_charSpaceWidth = charSpaceWidth; AscentLine = ascentLine; DecentLine = decentLine; m_orientationVector = m_endLocation.Subtract(m_startLocation); if (m_orientationVector.Length == 0) m_orientationVector = new Vector(1, 0, 0); m_orientationVector = m_orientationVector.Normalize(); m_orientationMagnitude = (int)(Math.Atan2(m_orientationVector[iTextSharp.text.pdf.parser.Vector.I2], m_orientationVector[iTextSharp.text.pdf.parser.Vector.I1]) * 1000); // see http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html // the two vectors we are crossing are in the same plane, so the result will be purely // in the z-axis (out of plane) direction, so we just take the I3 component of the result iTextSharp.text.pdf.parser.Vector origin = new iTextSharp.text.pdf.parser.Vector(0, 0, 1); m_distPerpendicular = (int)(m_startLocation.Subtract(origin)).Cross(m_orientationVector)[iTextSharp.text.pdf.parser.Vector.I3]; m_distParallelStart = m_orientationVector.Dot(m_startLocation); m_distParallelEnd = m_orientationVector.Dot(m_endLocation); }