Ejemplo n.º 1
0
 public PdfAutoBox(PdfRect rectangle, PdfBoxLayout box_layout = null)
     : this(rectangle.UpperLeft, PdfGrow.None, PdfAlign.Far, rectangle.Area, null, null, box_layout)
 {
 }
Ejemplo n.º 2
0
 public PdfAutoBox(PdfXY upper_left, PdfGrow grow_direction, PdfArea area = null, PdfArea max_area = null, PdfBorder borders = null, PdfBoxLayout box_layout = null)
     : this(upper_left, grow_direction, PdfAlign.Far, area ?? new PdfArea(0, 0), max_area, borders, box_layout)
 {
 }
Ejemplo n.º 3
0
 public PdfAutoBox(PdfRect rectangle, PdfAlign v_align, PdfBorder borders = null, PdfBoxLayout box_layout = null)
     : this(rectangle.UpperLeft, PdfGrow.None, v_align, rectangle.Area, null, borders, box_layout)
 {
 }
Ejemplo n.º 4
0
 public PdfAutoBox(PdfXY upper_left, PdfGrow grow_direction, PdfAlign v_align, PdfArea area, PdfArea max_area = null, PdfBorder borders = null, PdfBoxLayout box_layout = null)
     : base(borders, box_layout)
 {
     UpperLeft     = upper_left;
     GrowDirection = grow_direction;
     VAlign        = v_align;
     Area          = area;
     MaxArea       = max_area ?? new PdfArea(max_box_size, max_box_size);
 }
Ejemplo n.º 5
0
 public PdfAngledBox(PdfRect rect, PdfAngle angle, PdfAlign v_align, PdfBorder borders = null, PdfBoxLayout box_layout = null)
     : base(borders, box_layout)
 {
     Rectangle = rect;
     Angle     = angle;
     VAlign    = v_align;
 }
Ejemplo n.º 6
0
 public PdfOuterBox(PdfBorder borders = null, PdfBoxLayout box_layout = null)
     : base(borders, box_layout)
 {
 }
Ejemplo n.º 7
0
 public PdfBox(PdfBorder borders, PdfBoxLayout box_layout)
 {
     BoxLayout = box_layout;
     Borders   = borders ?? new PdfBorder(0, 0);
 }
Ejemplo n.º 8
0
        // desenhar retângulo em torno do elemento
        protected static byte[] DrawBox(PdfBoxLayout box_layout, double width, double height)
        {
            List <byte> contents = new List <byte>();

            contents.AddRange(Util.StringToBytes($"q\n"));

            if ((box_layout.Style & PdfBoxStyle.Stroke) > 0)
            {
                // configurar largura e cor da linha
                contents.AddRange(Util.StringToBytes($"{Util.FormatDouble(box_layout.Thickness)} w\n"));
                contents.AddRange(Util.StringToBytes($"{Util.FormatDouble(box_layout.StrokeColor.Red)} {Util.FormatDouble(box_layout.StrokeColor.Green)} {Util.FormatDouble(box_layout.StrokeColor.Blue)} RG\n"));
            }

            if ((box_layout.Style & PdfBoxStyle.Fill) > 0)
            {
                // configurar cor do preenchimento
                contents.AddRange(Util.StringToBytes($"{Util.FormatDouble(box_layout.FillColor.Red)} {Util.FormatDouble(box_layout.FillColor.Green)} {Util.FormatDouble(box_layout.FillColor.Blue)} rg\n"));
            }

            if (box_layout.LineDash != null)
            {
                // configurar linha tracejada
                contents.AddRange(Util.StringToBytes($"[{Util.FormatDouble(box_layout.LineDash.StrokeLength)} {Util.FormatDouble(box_layout.LineDash.SpaceLength)}] 0 d\n"));
            }

            if (((box_layout.Style & PdfBoxStyle.Fill) > 0) || ((box_layout.Style == PdfBoxStyle.Stroke) && box_layout.DrawTop && box_layout.DrawBottom && box_layout.DrawLeft && box_layout.DrawRight))
            {
                if (box_layout.CornerCurve == null)
                {
                    // plotar contorno sem curvas
                    contents.AddRange(Util.StringToBytes($"{0} {0} {Util.FormatDouble(width)} {Util.FormatDouble(height)} re\n"));
                }
                else
                {
                    // plotar contorno com curvas
                    double curve_width  = box_layout.CornerCurve.Width;
                    double curve_height = box_layout.CornerCurve.Heigth;

                    // desenhar curva superior esquerda
                    contents.AddRange(Util.StringToBytes(
                                          $"{Util.FormatDouble(0)} {Util.FormatDouble(height - curve_height)} m\n"));

                    contents.AddRange(Util.StringToBytes(
                                          $"{Util.FormatDouble(0)} {Util.FormatDouble(height)}\x20" +
                                          $"{Util.FormatDouble(0)} {Util.FormatDouble(height)}\x20" +
                                          $"{Util.FormatDouble(0 + curve_width)} {Util.FormatDouble(height)} c\n"));

                    // desenhar linha de cima
                    contents.AddRange(Util.StringToBytes(
                                          $"{Util.FormatDouble(width - curve_width)} {Util.FormatDouble(height)} l\n"));

                    // desenhar curva superior direita
                    contents.AddRange(Util.StringToBytes(
                                          $"{Util.FormatDouble(width)} {Util.FormatDouble(height)}\x20" +
                                          $"{Util.FormatDouble(width)} {Util.FormatDouble(height)}\x20" +
                                          $"{Util.FormatDouble(width)} {Util.FormatDouble(height - curve_height)} c\n"));

                    // desenhar linha direita
                    contents.AddRange(Util.StringToBytes(
                                          $"{Util.FormatDouble(width)} {Util.FormatDouble(0 + curve_height)} l\n"));

                    // desenhar curva inferior direita
                    contents.AddRange(Util.StringToBytes(
                                          $"{Util.FormatDouble(width)} {Util.FormatDouble(0)}\x20" +
                                          $"{Util.FormatDouble(width)} {Util.FormatDouble(0)}\x20" +
                                          $"{Util.FormatDouble(width - curve_width)} {Util.FormatDouble(0)} c\n"));

                    // desenhar linha de baixo
                    contents.AddRange(Util.StringToBytes(
                                          $"{Util.FormatDouble(0 + curve_width)} {Util.FormatDouble(0)} l\n"));

                    // desenhar curva inferior esquerda
                    contents.AddRange(Util.StringToBytes(
                                          $"{Util.FormatDouble(0)} {Util.FormatDouble(0)}\x20" +
                                          $"{Util.FormatDouble(0)} {Util.FormatDouble(0)}\x20" +
                                          $"{Util.FormatDouble(0)} {Util.FormatDouble(0 + curve_height)} c\n"));

                    // desenhar linha esquerda
                    contents.AddRange(Util.StringToBytes("h\x20"));
                }

                switch (box_layout.Style)
                {
                // pintar contorno
                case PdfBoxStyle.Stroke:
                    contents.AddRange(Util.StringToBytes($"S\n"));
                    break;

                // pintar preenchimento
                case PdfBoxStyle.Fill:
                    contents.AddRange(Util.StringToBytes($"f\n"));
                    break;

                // pintar contorno e preenchimento
                case PdfBoxStyle.StrokeFill:
                    contents.AddRange(Util.StringToBytes($"B\n"));
                    break;
                }
            }
            else if (box_layout.Style == PdfBoxStyle.Stroke)
            {
                if (box_layout.DrawTop)
                {
                    // desenhar linha de cima
                    contents.AddRange(Util.StringToBytes(
                                          $"{0} {Util.FormatDouble(height)} m\n" +
                                          $"{Util.FormatDouble(width)} {Util.FormatDouble(height)} l S\n"));
                }

                if (box_layout.DrawBottom)
                {
                    // desenhar linha de baixo
                    contents.AddRange(Util.StringToBytes(
                                          $"{0} {0} m\n" +
                                          $"{Util.FormatDouble(width)} {0} l S\n"));
                }

                if (box_layout.DrawLeft)
                {
                    // desenhar linha da esquerda
                    contents.AddRange(Util.StringToBytes(
                                          $"{0} {0} m\n" +
                                          $"{0} {Util.FormatDouble(height)} l S\n"));
                }

                if (box_layout.DrawRight)
                {
                    // desenhar linha da direita
                    contents.AddRange(Util.StringToBytes(
                                          $"{Util.FormatDouble(width)} {0} m\n" +
                                          $"{Util.FormatDouble(width)} {Util.FormatDouble(height)} l S\n"));
                }
            }

            contents.AddRange(Util.StringToBytes($"Q\n"));
            return(contents.ToArray());
        }