Ejemplo n.º 1
0
        private PdfTextElement BuildTextElement()
        {
            PdfTextElement textElem = new PdfTextElement();

            textElem.Font        = _font;
            textElem.FontSize    = _fontSize;
            textElem.Matrix      = _textMatrixCurrent.Multiply(_graphicsMatrix);
            textElem.RawText     = _sbText.ToString();
            textElem.VisibleText = PdfString_ToUnicode(textElem.RawText, _font);
            PdfCharElement lastChar = _listCharacters[_listCharacters.Count - 1];

            textElem.VisibleWidth  = (lastChar.Displacement + lastChar.Width) * textElem.Matrix.Matrix[0, 0];
            textElem.VisibleHeight = (_font.Height * _fontSize) * textElem.Matrix.Matrix[1, 1];
            textElem.Characters    = new List <PdfCharElement>();
            foreach (PdfCharElement c in _listCharacters)
            {
                textElem.Characters.Add(new PdfCharElement
                {
                    Char         = c.Char,
                    Displacement = (c.Displacement * textElem.Matrix.Matrix[0, 0]),
                    Width        = (c.Width * textElem.Matrix.Matrix[0, 0]),
                });
            }
            textElem.Childs = new List <PdfTextElement>();
            return(textElem);
        }
Ejemplo n.º 2
0
        public PdfTextElement SubPart(int startIndex, int endIndex)
        {
            PdfTextElement blockElem = new PdfTextElement
            {
                Font          = null,
                FontSize      = FontSize,
                Matrix        = Matrix.Copy(),
                RawText       = RawText.Substring(startIndex, endIndex - startIndex),
                VisibleText   = VisibleText.Substring(startIndex, endIndex - startIndex),
                VisibleWidth  = 0,
                VisibleHeight = VisibleHeight,
                Characters    = new List <PdfCharElement>(),
                Childs        = new List <PdfTextElement>(),
            };
            double displacement = Characters[startIndex].Displacement;

            blockElem.Matrix.Matrix[0, 2] += displacement;
            for (int j = startIndex; j < endIndex; j++)
            {
                blockElem.Characters.Add(new PdfCharElement
                {
                    Char         = Characters[j].Char,
                    Displacement = Characters[j].Displacement - displacement,
                    Width        = Characters[j].Width,
                });
            }
            PdfCharElement lastChar = blockElem.Characters[blockElem.Characters.Count - 1];

            blockElem.VisibleWidth = lastChar.Displacement + lastChar.Width;
            foreach (PdfTextElement elem in Childs)
            {
                blockElem.Childs.Add(elem);
            }

            return(blockElem);
        }