예제 #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);
            }
        }
 public PdfRectangle(PdfDistance llx, PdfDistance lly, PdfDistance urx, PdfDistance ury)
 {
     this.llx = llx;
     this.lly = lly;
     this.urx = urx;
     this.ury = ury;
 }
예제 #3
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);
            }
        }
예제 #4
0
 public PdfStyleText()
 {
     _locked      = false;
     _font        = null;
     _fontSize    = new PdfDistance(12.0);
     _lineSpacing = 1;
     _textColor   = null;
 }
예제 #5
0
        public PdfDistance         CharWidth(PdfDistance FontSize, char c)
        {
            if (Encode(c) == '?')
            {
                c = '?';
            }

            AfmCharMetric metric = _charMetric[c];

            return(new PdfDistance(FontSize.pnts * (double)(metric != null ? metric.Width : _fontBBox.urX) / 1000.0));
        }
 public PdfStyleLine()
 {
     _locked     = false;
     _lineColor  = null;
     _lineWidth  = new PdfDistance(1.0);
     _capStyle   = PdfLineCapStyle.Butt;
     _joinStyle  = PdfLineJoinStyle.Bevel;
     _miterLimit = 1.0;
     _dashArray  = null;
     _dashPhase  = new PdfDistance(0);
 }
예제 #7
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;
        }
예제 #8
0
        public PdfStyleText(PdfFont font, PdfDistance size)
        {
            if (font is null)
            {
                throw new ArgumentNullException(nameof(font));
            }

            _locked      = true;
            _font        = font;
            _fontSize    = size;
            _lineSpacing = 1.1;
            _textColor   = PdfColorCMYK.ncBlack;
        }
예제 #9
0
        public void                                opSelectFont(PdfFont font, PdfDistance size)
        {
            if (font is null)
            {
                throw new ArgumentNullException(nameof(font));
            }

            WriteResourceName(font);
            WriteNumber(size.pnts, 2, true);
            WriteStr(bs_Tf);
            _curFont     = font;
            _curFontSize = size;
        }
예제 #10
0
        public PdfStyleText(PdfFont font, PdfDistance size, double lineSpacing, PdfColor textColor)
        {
            if (font is null)
            {
                throw new ArgumentNullException(nameof(font));
            }

            _locked      = true;
            _font        = font;
            _fontSize    = size;
            _lineSpacing = lineSpacing;
            _textColor   = textColor;
        }
예제 #11
0
 private void                                _init()
 {
     _resources              = new PdfResourceEntryList();
     _dataStream             = new StreamBuffer();
     _curStrokeColorSpace    = null;
     _curNonStrokeColorSpace = null;
     _curStrokeColor         = null;
     _curNonStrokeColor      = null;
     _curLineWidth           = new PdfDistance(-1);
     _curLineCap             = PdfLineCapStyle.Unknown;
     _curLineJoin            = PdfLineJoinStyle.Unknown;
     _curMiterLimit          = -1;
     _curDashArray           = null;
     _curDashPhase           = new PdfDistance(-1);
 }
        public PdfStyleLine(PdfColor lineColor, PdfDistance lineWidth)
        {
            if (lineColor is null)
            {
                throw new ArgumentNullException(nameof(lineColor));
            }

            _locked     = true;
            _lineColor  = lineColor;
            _lineWidth  = lineWidth;
            _capStyle   = PdfLineCapStyle.Butt;
            _joinStyle  = PdfLineJoinStyle.Bevel;
            _miterLimit = 1.0;
            _dashArray  = null;
            _dashPhase  = new PdfDistance(0);
        }
        public PdfStyleLine(PdfStyleLine style)
        {
            if (style is null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            _locked     = false;
            _lineColor  = style._lineColor;
            _lineWidth  = style._lineWidth;
            _capStyle   = style._capStyle;
            _joinStyle  = style._joinStyle;
            _miterLimit = style._miterLimit;
            _dashArray  = style._dashArray;
            _dashPhase  = style._dashPhase;
        }
        public PdfStyleLine(PdfColor lineColor, PdfDistance lineWith, PdfLineCapStyle CapStyle, PdfLineJoinStyle joinStyle, double miterLimit, PdfDistance[] dashArray, PdfDistance dashPhase)
        {
            if (lineColor is null)
            {
                throw new ArgumentNullException(nameof(lineColor));
            }

            _locked     = true;
            _lineColor  = lineColor;
            _lineWidth  = lineWith;
            _capStyle   = CapStyle;
            _joinStyle  = joinStyle;
            _miterLimit = miterLimit;
            _dashArray  = dashArray;
            _dashPhase  = dashPhase;
        }
예제 #15
0
        public void                                opSetDash(PdfDistance[] dashArray, PdfDistance dashPhase)
        {
            WriteByte((byte)'[');

            if (dashArray != null)
            {
                for (int i = 0; i < dashArray.Length; ++i)
                {
                    WriteNumber(dashArray[i].pnts, 2, i < dashArray.Length - 1);
                }
            }

            WriteByte((byte)']');
            WriteByte((byte)' ');
            WriteNumber(dashPhase.pnts, 2, true);
            WriteStr(bs_d);

            _curDashArray = dashArray;
            _curDashPhase = dashPhase;
        }
예제 #16
0
        public PdfDistance         TextWidth(PdfDistance fontSize, string text)
        {
            int width = 0;

            if (text != null)
            {
                for (int i = 0; i < text.Length; ++i)
                {
                    char c = text[i];

                    if (Encode(c) == '?')
                    {
                        c = '?';
                    }

                    AfmCharMetric Metric = _charMetric[c];

                    width += (Metric != null) ? Metric.Width : _fontBBox.urX;
                }
            }

            return(new PdfDistance(fontSize.pnts * (double)width / 1000.0));
        }
예제 #17
0
 public PdfSize(PdfDistance width, PdfDistance height)
 {
     this.width  = width;
     this.height = height;
 }
예제 #18
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);
     }
 }
예제 #19
0
 public void                                opSetLineWidth(PdfDistance width)
 {
     WriteNumber(width.pnts, 2, true);
     WriteStr(bs_w);
     _curLineWidth = width;
 }
예제 #20
0
 public PdfPoint        SubY(PdfDistance d)
 {
     return(new PdfPoint(x, y - d));
 }
예제 #21
0
 public PdfPoint        SubX(PdfDistance d)
 {
     return(new PdfPoint(x - d, y));
 }
예제 #22
0
 public PdfPoint        AddY(PdfDistance d)
 {
     return(new PdfPoint(x, y + d));
 }
예제 #23
0
 public PdfPoint        AddX(PdfDistance d)
 {
     return(new PdfPoint(x + d, y));
 }
예제 #24
0
 public PdfPoint(PdfDistance x, PdfDistance y)
 {
     this.x = x;
     this.y = y;
 }