The Question
The PDF toolkit iText(Sharp) has its own vector type, implementing Substract
, Dot
product Cross
product and Multiply
, but I do not see an addition of vectors nor a projection of one vector onto antother.
Is there a simple way to do that?
The context
I am implementing an ITextExtractionStrategy
that collects text into chunks (class MyTextChunk
) if they
- are on the same line
renderInfo.GetBaseline()
- follow closely to avoid concatenating texts from different columns in a table
- and have the same height:
renderInfo .GetAscentLine().GetStartPoint() .Subtract(renderInfo .GetDescentLine() .GetStartPoint()) .Length
If I encounter a single smaller superscript character (i.e. above the base line, but not above the ascent line), I suppose this is to be a referred to later in the text and store it as char referable
in the chunk.
If the this referable
is followed close enough by more text, this text must be included in the chunk. Therefore, I need to extend the baseline till after the referable character. So I thought writing something like
public bool Append(TextRenderInfo renderInfo)
{
...
if (thisIsAReferable)
{
this.referable = infoText.Trim()[0];
Vector offsetVector = baseVector.Multiply(
baseVector.Dot(renderInfo.GetBaseline().GetEndPoint()
.Subtract(this.baseline.GetStartPoint()))
/ baseVector.LengthSquared);
this.baseline = new LineSegment(this.baseline.GetStartPoint(),
this.baseline.GetStartPoint().Add(offsetVector));
...
return true;
}
...
}
Remark: The calculation of offsetVector is not yet verified.