How to add / design iTextSharp vectors

Question

Toolkit PDF iText (Sharp) has its own own vector type that implements the product Substract, Dotproduct product Crossand Multiply, but I do not see the addition of vectors or the projection of one vector on antother.

Is there an easy way to do this?

Context

I implement ITextExtractionStrategythat collects text into chunks ( class MyTextChunk) if they

  • are on the same line renderInfo.GetBaseline()
  • Watch carefully to avoid concatenation of texts from different columns in the table.
  • and have the same height: renderInfo .GetAscentLine().GetStartPoint() .Subtract(renderInfo .GetDescentLine() .GetStartPoint()) .Length

If I come across a single smaller superscript (i.e. above the baseline, but not above the ascension line), I believe that this will be mentioned later in the text and save it as char referablea piece.

If for this reason referableenough to follow more text, this text should be included in the piece. Therefore, I need to extend the baseline to a reference character . So I thought to write 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;
        }
        ...
    }

Note: the offsetVector calculation has not yet been verified.

0
source share
1 answer

Vector PDF . : PDF LineSegment: , , , , , , , , . A LineSegment Vector, , .

PDF X, , Y, . MediaBox ( PDF).

(*). , :

enter image description here

( cm) 6 : a, b, c, d, e f. 9 , .

, a d 1; b c 0. X, e; Y, f.

, b, c, e f 0 a, X, d, Y. . ISO-32000-1.

() cross() , 6 .

Vector, 6 cm, Matrix.

(*) PDF . ! , . , , , , .

+1

Source: https://habr.com/ru/post/1614265/


All Articles