Esempio n. 1
0
        public void                                Text(PdfStyleText textStyle, PdfPoint point, PdfTextAlign align, string txt)
        {
            if (textStyle is null)
            {
                throw new ArgumentNullException(nameof(textStyle));
            }

            if (!string.IsNullOrEmpty(txt))
            {
                SetTextStyle(textStyle);

                if (align != PdfTextAlign.Left)
                {
                    PdfDistance Width = textStyle.Font.TextWidth(textStyle.FontSize, txt);

                    switch (align)
                    {
                    case PdfTextAlign.Right:    point.x -= Width;       break;

                    case PdfTextAlign.Center:   point.x -= Width / 2;   break;
                    }
                }

                SetTextMatrixH(point);
                opShowText(txt, 0, txt.Length);
            }
        }
Esempio n. 2
0
        public void                                Text(PdfStyleText textStyle, PdfPoint point, PdfTextAlign align, double rotation, string txt)
        {
            if (textStyle is null)
            {
                throw new ArgumentNullException(nameof(textStyle));
            }

            if (!string.IsNullOrEmpty(txt))
            {
                SetTextStyle(textStyle);

                rotation *= Math.PI / 180.0;

                double Rotation_Sin = Math.Round(Math.Sin(rotation), 5);
                double Rotation_Cos = Math.Round(Math.Cos(rotation), 5);

                if (align != PdfTextAlign.Left)
                {
                    PdfDistance Width = textStyle.Font.TextWidth(textStyle.FontSize, txt);

                    if (align == PdfTextAlign.Center)
                    {
                        Width = Width / 2.0;
                    }

                    point.x -= Width * Rotation_Cos;
                    point.y -= Width * Rotation_Sin;
                }

                SetTextMatrix(point, Rotation_Sin, Rotation_Cos);
                opShowText(txt, 0, txt.Length);
            }
        }
Esempio n. 3
0
 public void                                TextBox(PdfPoint upperLeftCorner, PdfStyleText style, PdfTextAlign align, PdfDistance width, int maxLines, string text)
 {
     if (!string.IsNullOrEmpty(text))
     {
         Formatter.TextBox TextBox = new Formatter.TextBox(style, align, width, maxLines, text);
         TextBox.Print(upperLeftCorner, this);
     }
 }
Esempio n. 4
0
        public PdfStyleText(PdfStyleText style)
        {
            if (style is null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            _locked      = false;
            _font        = style._font;
            _fontSize    = style._fontSize;
            _lineSpacing = style._lineSpacing;
            _textColor   = style._textColor;
        }
Esempio n. 5
0
        public void                                SetTextStyle(PdfStyleText style)
        {
            if (style is null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            if (style.TextColor != _curNonStrokeColor)
            {
                if (style.TextColor.ColorSpace != _curNonStrokeColorSpace)
                {
                    opSetNonStrokeColorSpace(style.TextColor.ColorSpace);
                }

                opSetNonStrokeColor(style.TextColor);
            }

            if (style.Font != _curFont || style.FontSize != _curFontSize)
            {
                opSelectFont(style.Font, style.FontSize);
            }
        }