internal override void                boxPrintForground(PdfPoint upperLeftCorner, PdfContent content)
        {
            content.DrawRectangle(null, PdfStyleFill.SolidWhite, upperLeftCorner, new PdfSize(_width, _height));

            PdfDistance widthNarrow;
            PdfDistance widthWidth;
            PdfDistance widthGap;

            widthNarrow = _width / ((_text.Length + 2) * (3 * 3 + 6) + (_text.Length + 1) * 1);

            if (widthNarrow > PdfDistance.d_pnt(1.5))
            {
                widthWidth = widthNarrow * 3;
                widthGap   = widthNarrow;
            }
            else
            {
                widthNarrow = _width / ((_text.Length + 2) * (2.2 * 3 + 6) + (_text.Length + 1) * 1);
                widthWidth  = widthNarrow * 2.2;
                widthGap    = widthNarrow;
            }

            PdfDistance X = upperLeftCorner.x;

            _writeBarcode(content, widthNarrow, widthWidth, ref X, upperLeftCorner.y, _startStop);
            X += widthGap;

            for (int i = 0; i < _text.Length; ++i)
            {
                _writeBarcode(content, widthNarrow, widthWidth, ref X, upperLeftCorner.y, _charEncoding[_text[i]]);
                X += widthGap;
            }

            _writeBarcode(content, widthNarrow, widthWidth, ref X, upperLeftCorner.y, _startStop);
        }
 public void                AddText(PdfDistance left, PdfDistance top, PdfDistance width, PdfStyleText style, PdfTextAlign align, int maxLines, string text)
 {
     Append(new TextBox(style, align, maxLines, text)
     {
         Fixed = true, Left = left, Top = top, Width = width
     });
 }
 public ContainerBox()
 {
     _border     = null;
     _children   = new BoxList(this);
     _calcWidth  = PdfDistance.NaN;
     _calcHeight = PdfDistance.NaN;
     _setWidth   = PdfDistance.NaN;
 }
        public Barcode39Box(PdfDistance width, PdfDistance height, string text)
        {
            if (text is null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            _validateText(text);
            _width  = width;
            _height = height;
            _text   = text;
        }
        private void                _writeBarcode(PdfContent content, PdfDistance widthNarrow, PdfDistance widthWide, ref PdfDistance x, PdfDistance y, UInt16 barcode)
        {
            for (int i = 1 << 8; i > 0; i = i >> 1)
            {
                PdfDistance w = (barcode & i) != 0 ? widthWide : widthNarrow;

                if ((i & 0x155) != 0)
                {
                    content.DrawRectangle(null, PdfStyleFill.SolidBlack, new PdfPoint(x, y), new PdfSize(w, _height));
                }

                x += w;
            }
        }
Esempio n. 6
0
        public TextBox(PdfStyleText style, PdfTextAlign align, int maxLines, string text)
        {
            if (style is null)
            {
                throw new ArgumentNullException(nameof(style));
            }
            if (text is null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            _setWidth = PdfDistance.NaN;
            _style    = style;
            _align    = align;
            _maxLines = maxLines;
            _text     = text;
        }
Esempio n. 7
0
        internal override void            boxPrintForground(PdfPoint upperLeftCorner, PdfContent content)
        {
            if (_lines == null)
            {
                _format();
            }

            PdfDistance LineHeight = _style.LineHeight;
            PdfDistance YOffset    = _style.YOffset;

            upperLeftCorner += new PdfPoint(Left, Top);

            content.SetTextStyle(_style);

            for (int l = 0; l < _lines.Length; ++l)
            {
                upperLeftCorner.y.pnts -= LineHeight.pnts;
                content.SetTextMatrixH(upperLeftCorner + new PdfPoint(_lines[l].Left, YOffset));
                content.opShowText(Text, _lines[l].StrBegin, _lines[l].StrLength);
            }
        }
        public TableColumns(TableBox table, PdfDistance[] columWidth)
        {
            if (table is null)
            {
                throw new ArgumentNullException(nameof(table));
            }
            if (columWidth is null)
            {
                throw new ArgumentNullException(nameof(columWidth));
            }

            _table = table;

            PdfDistance left = PdfDistance.Zero;

            for (int col = 0; col < columWidth.Length; ++col)
            {
                base.Add(new TableColumn(_table, left, columWidth[col]));
                left += columWidth[col];
            }
        }
        public override void                Format()
        {
            PdfDistance innerWidth = _setWidth;
            PdfDistance top        = PdfDistance.Zero;
            PdfDistance left       = PdfDistance.Zero;

            _calcWidth  = !_setWidth.IsNaN ? _setWidth : PdfDistance.Zero;
            _calcHeight = PdfDistance.Zero;

            if (_margin != null)
            {
                top  -= _margin.Top;
                left += _margin.Left;
            }

            if (_border != null)
            {
                top  -= _border.TopHeight;
                left += _border.LeftWidth;

                if (!innerWidth.IsNaN)
                {
                    innerWidth -= _border.TotalWidth;
                }
            }

            if (_padding != null)
            {
                top  -= _padding.Top;
                left += _padding.Left;
            }

            for (int i = 0; i < _children.Count; ++i)
            {
                if (!_children[i].Fixed)
                {
                    _children[i].boxMoveTo(top, left);

                    if (!innerWidth.IsNaN)
                    {
                        _children[i].Width = innerWidth;
                    }

                    _children[i].Format();

                    top += _children[i].Height;
                }

                if (_calcWidth < _children[i].Left + _children[i].Width)
                {
                    _calcWidth = _children[i].Left + _children[i].Width;
                }

                if (_calcHeight > _children[i].Top + _children[i].Height)
                {
                    _calcHeight = _children[i].Top + _children[i].Height;
                }
            }

            if (_margin != null)
            {
                _calcWidth  += _margin.Right;
                _calcHeight -= _margin.Bottom;
            }

            if (_border != null)
            {
                _calcWidth  += _border.RightWidth;
                _calcHeight -= _border.BottomHeight;
            }

            if (_padding != null)
            {
                _calcWidth  += _padding.Right;
                _calcHeight -= _padding.Bottom;
            }
        }
Esempio n. 10
0
 internal void                boxSetTopHeight(PdfDistance top, PdfDistance height)
 {
     _top    = top;
     _height = height;
 }
Esempio n. 11
0
        public override void                Format()
        {
            PdfDistance top = PdfDistance.Zero;

            _calcWidth  = PdfDistance.Zero;
            _calcHeight = PdfDistance.Zero;

            for (int rowIndex = 0; rowIndex < _rows.Count; ++rowIndex)
            {
                TableRow    Row    = _rows[rowIndex];
                PdfDistance Height = PdfDistance.Zero;
                PdfDistance Width  = PdfDistance.Zero;

                for (int colIndex = 0; colIndex < Row.Cells.Count;)
                {
                    TableCell cell = Row.Cells[colIndex];

                    cell.boxMoveTo(top, cell.Column.Left);

                    if (cell.ColSpan == 1)
                    {
                        cell.Width = cell.Column.Width;
                    }
                    else
                    {
                        PdfDistance CellWidth = PdfDistance.Zero;

                        for (int i = 0; i < cell.ColSpan; ++i)
                        {
                            CellWidth += _columns[colIndex + i].Width;
                        }

                        cell.Width = CellWidth;
                    }

                    cell.Format();

                    if (Height > cell.Height)
                    {
                        Height = cell.Height;
                    }

                    if (Width < cell.Left + cell.Width)
                    {
                        Width = cell.Left + cell.Width;
                    }

                    colIndex += cell.ColSpan;
                }

                Row.boxSetTopHeight(top, Height);

                top += Height;

                if (_calcWidth < Width)
                {
                    _calcWidth = Width;
                }

                if (_calcHeight > top)
                {
                    _calcHeight = top;
                }
            }
        }
Esempio n. 12
0
 public Box()
 {
     _parent = null;
     _top    = PdfDistance.Zero;
     _left   = PdfDistance.Zero;
 }
Esempio n. 13
0
        private void            _format()
        {
            PdfDistance spaceWidth = _style.Font.CharWidth(_style.FontSize, ' ');

            TextLine[]  lines    = new TextLine[1];
            int         curPos   = 0;
            int         sepPos   = -1;
            PdfDistance curWidth = new PdfDistance(0);
            PdfDistance sepWidth = new PdfDistance(0);

            lines[0].StrBegin = 0;

            while (curPos < Text.Length)
            {
                char Chr = Text[curPos];

                if (Chr == '\n' || Chr == '\r')
                {
                    lines[lines.Length - 1].StrLength = curPos - lines[lines.Length - 1].StrBegin;
                    lines[lines.Length - 1].Width     = curWidth;
                    curWidth = new PdfDistance(0);

                    if (_maxLines > 0 && lines.Length >= _maxLines)
                    {
                        break;
                    }

                    Array.Resize <TextLine>(ref lines, lines.Length + 1);

                    ++curPos;

                    if (Chr == '\r' && curPos < Text.Length && Text[curPos] == '\n')
                    {
                        ++curPos;
                    }

                    lines[lines.Length - 1].StrBegin = curPos;
                    sepPos   = -1;
                    sepWidth = new PdfDistance(0);
                }
                else
                {
                    PdfDistance ChrWidth = (Chr == ' ') ? spaceWidth : _style.Font.CharWidth(_style.FontSize, Chr);

                    if (!_setWidth.IsNaN && _setWidth.pnts > 0 && curWidth + ChrWidth > _setWidth)
                    {
                        if (_maxLines == 0 || lines.Length < _maxLines)
                        {
                            if (sepWidth == new PdfDistance(0))
                            {
                                if (curWidth > new PdfDistance(0))
                                {
                                    sepPos   = curPos;
                                    sepWidth = curWidth;
                                }
                                else
                                {
                                    sepPos   = curPos + 1;
                                    sepWidth = Width;
                                }
                            }

                            lines[lines.Length - 1].StrLength = sepPos - lines[lines.Length - 1].StrBegin;
                            lines[lines.Length - 1].Width     = sepWidth;

                            Array.Resize <TextLine>(ref lines, lines.Length + 1);

                            lines[lines.Length - 1].StrBegin = sepPos;
                            curPos   = sepPos;
                            sepPos   = -1;
                            curWidth = new PdfDistance(0);
                            sepWidth = new PdfDistance(0);
                        }
                        else
                        {
                            lines[lines.Length - 1].StrLength = curPos - lines[lines.Length - 1].StrBegin;
                            lines[lines.Length - 1].Width     = curWidth;
                            curWidth = new PdfDistance(0);
                            break;
                        }
                    }
                    else
                    {
                        ++curPos;
                        curWidth += ChrWidth;

                        if (Chr == ' ')
                        {
                            sepPos   = curPos;
                            sepWidth = curWidth;
                        }
                    }
                }
            }

            if (curWidth.pnts > 0)
            {
                lines[lines.Length - 1].StrLength = curPos - lines[lines.Length - 1].StrBegin;
                lines[lines.Length - 1].Width     = curWidth;
            }

            _calcWidth = !_setWidth.IsNaN ? _setWidth : PdfDistance.Zero;

            for (int l = 0; l < lines.Length; ++l)
            {
                lines[l].Left = new PdfDistance(0);

                if (lines[l].Width > _calcWidth)
                {
                    _calcWidth = lines[l].Width;
                }
            }

            switch (_align)
            {
            case PdfTextAlign.Center:
                for (int l = 0; l < lines.Length; ++l)
                {
                    lines[l].Left = (_calcWidth - lines[l].Width) / 2;
                }
                break;

            case PdfTextAlign.Right:
                for (int l = 0; l < lines.Length; ++l)
                {
                    lines[l].Left = _calcWidth - lines[l].Width;
                }
                break;
            }

            for (int l = 0; l < lines.Length; ++l)
            {
                while (lines[l].StrLength > 0 && _text[lines[l].StrBegin + lines[l].StrLength - 1] == ' ')
                {
                    lines[l].Width -= spaceWidth;
                    --lines[l].StrLength;
                }

                while (lines[l].StrLength > 0 && _text[lines[l].StrBegin] == ' ')
                {
                    lines[l].Left += spaceWidth;
                    ++lines[l].StrBegin;
                    --lines[l].StrLength;
                }
            }

            _calcHeight = -Style.LineHeight * lines.Length;
            _lines      = lines;
        }
 public TableColumn(TableBox table, PdfDistance left, PdfDistance width)
 {
     _table    = table;
     _setLeft  = left;
     _setWidth = width;
 }
        public void                            DrawLineHorizontal(PdfStyleLine lineStyle, PdfPoint begin, PdfDistance length)
        {
            if (lineStyle is null)
            {
                throw new ArgumentNullException(nameof(lineStyle));
            }

            if (_horizontalLines == null)
            {
                _horizontalLines = new Lines();
            }

            _horizontalLines.Add(lineStyle, begin, new PdfPoint(begin.x + length, begin.y));
        }
        public void                            DrawLineVertical(PdfStyleLine lineStyle, PdfPoint begin, PdfDistance length)
        {
            if (lineStyle is null)
            {
                throw new ArgumentNullException(nameof(lineStyle));
            }

            if (_verticalLines == null)
            {
                _verticalLines = new Lines();
            }

            _verticalLines.Add(lineStyle, begin, new PdfPoint(begin.x, begin.y + length));
        }
Esempio n. 17
0
 internal void                boxMoveTo(PdfDistance top, PdfDistance left)
 {
     _top  = top;
     _left = left;
 }