public BlocoDestinatarioRemetenteNFC(DanfeViewModel viewModel, Estilo estilo, PrimitiveComposer primitiveComposer, float y) : base(viewModel, estilo)
        {
            primitiveComposer.BeginLocalState();
            primitiveComposer.SetFont(estilo.FonteCampoConteudo.FonteInterna, estilo.FonteCampoConteudo.Tamanho);

            if (viewModel.Destinatario != null && !string.IsNullOrWhiteSpace(viewModel?.Destinatario?.CnpjCpf))
            {
                var dest = viewModel?.Destinatario;

                primitiveComposer.ShowText("CONSUMIDOR", new PointF(140, y + 10), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);

                if (!string.IsNullOrWhiteSpace(dest.RazaoSocial))
                {
                    if (dest.RazaoSocial.Length > 30)
                    {
                        primitiveComposer.ShowText(dest.RazaoSocial.Substring(0, 30), new PointF(140, y + 20), XAlignmentEnum.Center, YAlignmentEnum.Top, 0);
                        primitiveComposer.ShowText(dest.RazaoSocial.Substring(30), new PointF(140, y + 30), XAlignmentEnum.Center, YAlignmentEnum.Top, 0);

                        y = y + 10;
                    }
                    else
                    {
                        primitiveComposer.ShowText($"NOME: {dest.RazaoSocial}", new PointF(140, y + 20), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
                    }
                }

                primitiveComposer.ShowText($"CNPJ/CPF: {dest.CnpjCpf}", new PointF(140, y + 30), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);


                if (!string.IsNullOrWhiteSpace(dest.EnderecoLogadrouro) &&
                    !string.IsNullOrWhiteSpace(dest.EnderecoNumero) &&
                    !string.IsNullOrWhiteSpace(dest.EnderecoBairro) &&
                    !string.IsNullOrWhiteSpace(dest.Municipio))
                {
                    primitiveComposer.ShowText($"{dest.EnderecoLogadrouro}, {dest.EnderecoNumero}, {dest.EnderecoBairro}, {dest.Municipio} - {dest.EnderecoUf}", new PointF(140, y + 40), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
                }

                Y_NFC = y + 50;

                primitiveComposer.DrawLine(new PointF(15, Y_NFC), new PointF(265, Y_NFC));
                primitiveComposer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));

                primitiveComposer.Stroke();
                primitiveComposer.End();
            }
            else
            {
                primitiveComposer.ShowText("CONSUMIDOR NÃO IDENTIFICADO", new PointF(140, y + 10), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);

                Y_NFC = y + 20;

                primitiveComposer.DrawLine(new PointF(15, Y_NFC), new PointF(265, Y_NFC));
                primitiveComposer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));

                primitiveComposer.Stroke();
                primitiveComposer.End();
            }
        }
Exemplo n.º 2
0
 private void DrawCross(
     PrimitiveComposer composer,
     PointF center
     )
 {
     composer.DrawLine(
         new PointF(center.X - 10, center.Y),
         new PointF(center.X + 10, center.Y)
         );
     composer.DrawLine(
         new PointF(center.X, center.Y - 10),
         new PointF(center.X, center.Y + 10)
         );
     composer.Stroke();
 }
Exemplo n.º 3
0
        public BlocoFormaPagamentoNFC(DanfeViewModel viewModel, Estilo estilo, PrimitiveComposer primitiveComposer, float y) : base(estilo)
        {
            primitiveComposer.BeginLocalState();
            primitiveComposer.SetFont(estilo.FonteCampoConteudo.FonteInterna, estilo.FonteCampoConteudo.Tamanho);
            primitiveComposer.ShowText("FORMAS DE PAGAMENTO", new PointF(25, y + 10), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText("VALOR PAGO", new PointF(250, y + 10), XAlignmentEnum.Right, YAlignmentEnum.Middle, 0);
            //primitiveComposer.ShowText("Troco", new PointF(160, y + 10), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0);

            y = y + 10;

            foreach (var item in viewModel.Pagamento)
            {
                foreach (var detalhe in item.DetalhePagamento)
                {
                    y = y + 10;

                    primitiveComposer.ShowText(detalhe.FormaPagamento.FormaPagamentoToString(), new PointF(25, y), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0);
                    primitiveComposer.ShowText(detalhe.Valor.Formatar(), new PointF(250, y), XAlignmentEnum.Right, YAlignmentEnum.Middle, 0);
                }
            }

            Y_NFC = y + 10;

            primitiveComposer.DrawLine(new PointF(15, Y_NFC), new PointF(265, Y_NFC));
            primitiveComposer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));
            primitiveComposer.Stroke();
            primitiveComposer.End();
        }
        public BlocoIdentificacaoEmitenteNFC(DanfeViewModel viewModel, Estilo estilo, PrimitiveComposer primitiveComposer) : base(viewModel, estilo)
        {
            primitiveComposer.BeginLocalState();
            primitiveComposer.SetFont(estilo.FonteCampoTituloNegrito.FonteInterna, estilo.FonteCampoTituloNegrito.Tamanho);
            int y = 0;

            var emitente = viewModel.Emitente;

            if (emitente.RazaoSocial.Length > 39)
            {
                primitiveComposer.ShowText(emitente.RazaoSocial.Substring(0, 39), new PointF(140, 10), XAlignmentEnum.Center, YAlignmentEnum.Top, 0);
                primitiveComposer.ShowText(emitente.RazaoSocial.Substring(39), new PointF(140, 20), XAlignmentEnum.Center, YAlignmentEnum.Top, 0);

                primitiveComposer.ShowText($"CNPJ - {Formatador.FormatarCnpj(emitente.CnpjCpf)}", new PointF(140, 30), XAlignmentEnum.Center, YAlignmentEnum.Top, 0);

                y = 30;
            }
            else
            {
                primitiveComposer.ShowText(emitente.RazaoSocial, new PointF(140, 10), XAlignmentEnum.Center, YAlignmentEnum.Top, 0);
                primitiveComposer.ShowText($"CNPJ - {Formatador.FormatarCnpj(emitente.CnpjCpf)}", new PointF(140, 20), XAlignmentEnum.Center, YAlignmentEnum.Top, 0);

                y = 20;
            }

            primitiveComposer.SetFont(estilo.FonteCampoConteudoNegrito.FonteInterna, estilo.FonteCampoConteudoNegrito.Tamanho);

            if (!string.IsNullOrWhiteSpace(emitente.EnderecoLogadrouro) &&
                !string.IsNullOrWhiteSpace(emitente.EnderecoNumero) &&
                !string.IsNullOrWhiteSpace(emitente.EnderecoBairro) &&
                !string.IsNullOrWhiteSpace(emitente.Municipio))
            {
                if (emitente.EnderecoLogadrouro.Length >= 25)
                {
                    primitiveComposer.ShowText($"{emitente.EnderecoLogadrouro.Substring(0, 25)}, {emitente.EnderecoNumero} - {emitente.EnderecoBairro} - {emitente.Municipio} - {emitente.EnderecoUf}",
                                               new PointF(140, y + 10), XAlignmentEnum.Center, YAlignmentEnum.Top, 0);
                }
                else
                {
                    primitiveComposer.ShowText($"{emitente.EnderecoLogadrouro}, {emitente.EnderecoNumero} - {emitente.EnderecoBairro} - {emitente.Municipio} - {emitente.EnderecoUf}",
                                               new PointF(140, y + 10), XAlignmentEnum.Center, YAlignmentEnum.Top, 0);
                }
            }
            primitiveComposer.DrawLine(new PointF(15, y + 20), new PointF(265, y + 20));
            primitiveComposer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));
            primitiveComposer.Stroke();
            primitiveComposer.End();

            Y_NFC = y + 20;
        }
Exemplo n.º 5
0
        public BlocoProdutoServicoTotalNFC(DanfeViewModel viewModel, Estilo estilo, PrimitiveComposer primitiveComposer, float y) : base(estilo)
        {
            primitiveComposer.BeginLocalState();

            primitiveComposer.SetFont(estilo.FonteCampoConteudo.FonteInterna, estilo.FonteCampoConteudo.Tamanho);
            primitiveComposer.ShowText("QNT. TOTAL DE ITENS", new PointF(25, y + 10), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText(viewModel.CalculoImposto.QuantidadeTotal.ToString(), new PointF(250, y + 10), XAlignmentEnum.Right, YAlignmentEnum.Middle, 0);

            primitiveComposer.ShowText("VALOR DOS PRODUTOS", new PointF(25, y + 20), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText(viewModel.CalculoImposto.ValorTotalProdutos.Formatar(), new PointF(250, y + 20), XAlignmentEnum.Right, YAlignmentEnum.Middle, 0);

            //if (viewModel.CalculoImposto.ValorFrete > 0)
            //{
            primitiveComposer.ShowText("Valor do Frete", new PointF(25, y + 30), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText(viewModel.CalculoImposto.ValorFrete.Formatar(), new PointF(250, y + 30), XAlignmentEnum.Right, YAlignmentEnum.Middle, 0);
            //}

            //if (viewModel.CalculoImposto.ValorSeguro > 0)
            //{
            primitiveComposer.ShowText("Valor do Seguro", new PointF(25, y + 40), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText(viewModel.CalculoImposto.ValorSeguro.Formatar(), new PointF(250, y + 40), XAlignmentEnum.Right, YAlignmentEnum.Middle, 0);
            //}

            //if (viewModel.CalculoImposto.OutrasDespesas > 0)
            //{
            primitiveComposer.ShowText("OUTRAS DESPESAS", new PointF(25, y + 50), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText(viewModel.CalculoImposto.OutrasDespesas.Formatar(), new PointF(250, y + 50), XAlignmentEnum.Right, YAlignmentEnum.Middle, 0);
            //}

            //if (viewModel.CalculoImposto.Desconto > 0)
            //{
            primitiveComposer.ShowText("DESCONTO (-)", new PointF(25, y + 60), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText(viewModel.CalculoImposto.Desconto.Formatar(), new PointF(250, y + 60), XAlignmentEnum.Right, YAlignmentEnum.Middle, 0);
            //}

            primitiveComposer.SetFont(estilo.FonteCampoTituloNegrito.FonteInterna, estilo.FonteCampoTituloNegrito.Tamanho);
            primitiveComposer.ShowText("VALOR TOTAL", new PointF(25, y + 70), XAlignmentEnum.Left, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText(viewModel.CalculoImposto.ValorTotalNota.Formatar(), new PointF(250, y + 70), XAlignmentEnum.Right, YAlignmentEnum.Middle, 0);

            Y_NFC = y + 80;

            primitiveComposer.DrawLine(new PointF(15, Y_NFC), new PointF(265, Y_NFC));
            primitiveComposer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));

            primitiveComposer.Stroke();
            primitiveComposer.End();
        }
Exemplo n.º 6
0
        public BlocoConsultaChaveNFC(DanfeViewModel viewModel, Estilo estilo, PrimitiveComposer primitiveComposer, float y) : base(estilo)
        {
            primitiveComposer.BeginLocalState();
            primitiveComposer.SetFont(estilo.FonteCampoConteudo.FonteInterna, estilo.FonteCampoConteudo.Tamanho);
            primitiveComposer.ShowText("Consulta pela chave de acesso em", new PointF(140, y + 10), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText(viewModel.EndConsulta, new PointF(140, y + 20), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText("CHAVE DE ACESSO", new PointF(140, y + 30), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText(viewModel.ChaveAcesso, new PointF(140, y + 40), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);

            Y_NFC = y + 50;

            primitiveComposer.DrawLine(new PointF(15, Y_NFC), new PointF(265, Y_NFC));
            primitiveComposer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));

            primitiveComposer.Stroke();
            primitiveComposer.End();
        }
Exemplo n.º 7
0
        protected override void ToXObjectInternal(PrimitiveComposer composer)
        {
            EmpresaViewModel empresa = null;

            if (Danfe.Model.TipoNF == 1)
            {
                empresa = Danfe.Model.Emitente;
            }
            else if (Danfe.Model.TipoNF == 0)
            {
                empresa = Danfe.Model.Destinatario;
            }
            else
            {
                throw new Exception("Tipo de NF não suportado.");
            }

            BlockComposer bComp = new BlockComposer(composer);

            composer.SafeDrawRectangle(RetNumeracao);
            composer.SafeDrawRectangle(RetRecebemos);

            composer.SetFont(Danfe.Font, 6);
            bComp.SafeBegin(RetRecebemos.GetPaddedRectangleMm(1), XAlignmentEnum.Left, YAlignmentEnum.Middle);
            bComp.ShowText(String.Format("RECEBEMOS DE {0} OS PRODUTOS E/OU SERVIÇOS CONSTANTES DA NOTA FISCAL ELETRÔNICA INDICADA ABAIXO.", empresa.Nome));
            bComp.End();

            // Numeração da NFe
            composer.SafeDrawRectangle(RetNumeracao);
            composer.SetFont(Danfe.FontBold, 12);
            bComp.SafeBegin(RetNumeracao, XAlignmentEnum.Center, YAlignmentEnum.Middle);
            bComp.ShowText(String.Format("NF-e\nNº {0}\nSérie {1}", Danfe.Model.NumeroNF.ToString(Formatador.FormatoNumeroNF), Danfe.Model.Serie));
            bComp.End();

            composer.Stroke();

            // Linha pontilhada
            composer.BeginLocalState();
            composer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));
            composer.DrawLine(new PointF(InternalRectangle.Left, Size.Height - MargemLinhaPontilhada), new PointF(InternalRectangle.Right, Size.Height - MargemLinhaPontilhada));
            composer.Stroke();
            composer.End();
        }
Exemplo n.º 8
0
        public BlocoInformacaoFiscal(DanfeViewModel viewModel, Estilo estilo, PrimitiveComposer primitiveComposer, float y) : base(estilo)
        {
            if (viewModel.TipoAmbiente == 2)
            {
                primitiveComposer.BeginLocalState();
                primitiveComposer.SetFont(estilo.FonteCampoConteudoNegrito.FonteInterna, estilo.FonteTamanhoMinimo + 1);
                primitiveComposer.ShowText("EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO - SEM VALOR FISCAL", new PointF(132.5F, y + 10), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);

                Y_NFC = y + 20;
                primitiveComposer.DrawLine(new PointF(15, Y_NFC), new PointF(265, Y_NFC));
                primitiveComposer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));
                primitiveComposer.Stroke();
                primitiveComposer.End();
            }
            else
            {
                Y_NFC = y;
            }
        }
Exemplo n.º 9
0
        public BlocoIdentificacaoNFC(DanfeViewModel viewModel, Estilo estilo, PrimitiveComposer primitiveComposer, float y) : base(estilo)
        {
            primitiveComposer.BeginLocalState();

            primitiveComposer.SetFont(estilo.FonteCampoTituloNegrito.FonteInterna, estilo.FonteCampoTituloNegrito.Tamanho);
            primitiveComposer.ShowText($"Nº: {viewModel?.NfNumero}  Série: {viewModel?.NfSerie}", new PointF(140, y + 10), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);

            primitiveComposer.SetFont(estilo.FonteCampoConteudoNegrito.FonteInterna, estilo.FonteCampoConteudoNegrito.Tamanho);
            primitiveComposer.ShowText($"{viewModel?.DataHoraEmissao} - Via Consumidor", new PointF(140, y + 20), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);

            primitiveComposer.SetFont(estilo.FonteCampoConteudo.FonteInterna, estilo.FonteCampoConteudo.Tamanho);
            primitiveComposer.ShowText("PROTOCOLO DE AUTORIZAÇÃO", new PointF(140, y + 30), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText($"{viewModel.ProtocoloAutorizacao}", new PointF(140, y + 40), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);

            Y_NFC = y + 50;

            primitiveComposer.DrawLine(new PointF(15, Y_NFC), new PointF(265, Y_NFC));
            primitiveComposer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));

            primitiveComposer.Stroke();
            primitiveComposer.End();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Print as linhas tracejadas na tabela, ignorando a última
        /// </summary>
        /// <param name="composer"></param>
        /// <param name="y">Lista com as posições y</param>
        /// <param name="xBegin"></param>
        /// <param name="xEnd"></param>
        private void PrintLinhasTracejadas(PrimitiveComposer composer, List <float> y, float xBegin, float xEnd)
        {
            if (xBegin < 0)
            {
                throw new ArgumentOutOfRangeException("xBegin");
            }

            if (xEnd > composer.Scanner.CanvasSize.Width)
            {
                throw new ArgumentOutOfRangeException("xEnd");
            }

            composer.BeginLocalState();
            composer.SetLineDash(new LineDash(new Double[] { 3, 2 }));
            for (int i = 0; i < y.Count - 1; i++)
            {
                composer.DrawLine(new PointF(xBegin, y[i]), new PointF(xEnd, y[i]));
            }

            composer.Stroke();
            composer.End();
        }
Exemplo n.º 11
0
 private void DrawCross(
     PrimitiveComposer composer,
     PointF center
     )
 {
     composer.DrawLine(
     new PointF(center.X-10,center.Y),
     new PointF(center.X+10,center.Y)
     );
       composer.DrawLine(
     new PointF(center.X,center.Y-10),
     new PointF(center.X,center.Y+10)
     );
       composer.Stroke();
 }
Exemplo n.º 12
0
        private void BuildMiscellaneousPage(
            Document document
            )
        {
            // 1. Add the page to the document!
            Page page = new Page(document); // Instantiates the page inside the document context.

            document.Pages.Add(page);       // Puts the page in the pages collection.

            SizeF pageSize = page.Size;

            // 2. Create a content composer for the page!
            PrimitiveComposer composer = new PrimitiveComposer(page);

            // 3. Drawing the page contents...
            composer.SetFont(
                new fonts::StandardType1Font(
                    document,
                    fonts::StandardType1Font.FamilyEnum.Courier,
                    true,
                    false
                    ),
                32
                );

            {
                BlockComposer blockComposer = new BlockComposer(composer);
                blockComposer.Begin(new RectangleF(30, 0, pageSize.Width - 60, 50), XAlignmentEnum.Center, YAlignmentEnum.Middle);
                blockComposer.ShowText("Miscellaneous");
                blockComposer.End();
            }

            composer.BeginLocalState();
            composer.SetLineJoin(LineJoinEnum.Round);
            composer.SetLineCap(LineCapEnum.Round);

            // 3.1. Polygon.
            composer.DrawPolygon(
                new PointF[]
            {
                new PointF(100, 200),
                new PointF(150, 150),
                new PointF(200, 150),
                new PointF(250, 200)
            }
                );

            // 3.2. Polyline.
            composer.DrawPolyline(
                new PointF[]
            {
                new PointF(300, 200),
                new PointF(350, 150),
                new PointF(400, 150),
                new PointF(450, 200)
            }
                );

            composer.Stroke();

            // 3.3. Rectangle (both squared and rounded).
            int x      = 50;
            int radius = 0;

            while (x < 500)
            {
                if (x > 300)
                {
                    composer.SetLineDash(new LineDash(new double[] { 5, 5 }, 3));
                }

                composer.SetFillColor(new DeviceRGBColor(1, x / 500d, x / 500d));
                composer.DrawRectangle(
                    new RectangleF(x, 250, 150, 100),
                    radius // NOTE: radius parameter determines the rounded angle size.
                    );
                composer.FillStroke();

                x      += 175;
                radius += 10;
            }
            composer.End(); // End local state.

            composer.BeginLocalState();
            composer.SetFont(
                composer.State.Font,
                12
                );

            // 3.4. Line cap parameter.
            int y = 400;

            foreach (LineCapEnum lineCap
                     in (LineCapEnum[])Enum.GetValues(typeof(LineCapEnum)))
            {
                composer.ShowText(
                    lineCap + ":",
                    new PointF(50, y),
                    XAlignmentEnum.Left,
                    YAlignmentEnum.Middle,
                    0
                    );
                composer.SetLineWidth(12);
                composer.SetLineCap(lineCap);
                composer.DrawLine(
                    new PointF(120, y),
                    new PointF(220, y)
                    );
                composer.Stroke();

                composer.BeginLocalState();
                composer.SetLineWidth(1);
                composer.SetStrokeColor(DeviceRGBColor.White);
                composer.SetLineCap(LineCapEnum.Butt);
                composer.DrawLine(
                    new PointF(120, y),
                    new PointF(220, y)
                    );
                composer.Stroke();
                composer.End(); // End local state.

                y += 30;
            }

            // 3.5. Line join parameter.
            y += 50;
            foreach (LineJoinEnum lineJoin
                     in (LineJoinEnum[])Enum.GetValues(typeof(LineJoinEnum)))
            {
                composer.ShowText(
                    lineJoin + ":",
                    new PointF(50, y),
                    XAlignmentEnum.Left,
                    YAlignmentEnum.Middle,
                    0
                    );
                composer.SetLineWidth(12);
                composer.SetLineJoin(lineJoin);
                PointF[] points = new PointF[]
                {
                    new PointF(120, y + 25),
                    new PointF(150, y - 25),
                    new PointF(180, y + 25)
                };
                composer.DrawPolyline(points);
                composer.Stroke();

                composer.BeginLocalState();
                composer.SetLineWidth(1);
                composer.SetStrokeColor(DeviceRGBColor.White);
                composer.SetLineCap(LineCapEnum.Butt);
                composer.DrawPolyline(points);
                composer.Stroke();
                composer.End(); // End local state.

                y += 50;
            }
            composer.End(); // End local state.

            // 3.6. Clipping.

            /*
             * NOTE: Clipping should be conveniently enclosed within a local state
             * in order to easily resume the unaltered drawing area after the operation completes.
             */
            composer.BeginLocalState();
            composer.DrawPolygon(
                new PointF[]
            {
                new PointF(220, 410),
                new PointF(300, 490),
                new PointF(450, 360),
                new PointF(430, 520),
                new PointF(590, 565),
                new PointF(420, 595),
                new PointF(460, 730),
                new PointF(380, 650),
                new PointF(330, 765),
                new PointF(310, 640),
                new PointF(220, 710),
                new PointF(275, 570),
                new PointF(170, 500),
                new PointF(275, 510)
            }
                );
            composer.Clip();
            // Showing a clown image...
            // Instantiate a jpeg image object!
            entities::Image   image        = entities::Image.Get(GetResourcePath("images" + System.IO.Path.DirectorySeparatorChar + "Clown.jpg")); // Abstract image (entity).
            xObjects::XObject imageXObject = image.ToXObject(document);

            // Show the image!
            composer.ShowXObject(
                imageXObject,
                new PointF(170, 320),
                GeomUtils.Scale(imageXObject.Size, new SizeF(450, 0))
                );
            composer.End(); // End local state.

            // 4. Flush the contents into the page!
            composer.Flush();
        }
Exemplo n.º 13
0
        protected override void ToXObjectInternal(PrimitiveComposer composer)
        {
            EmpresaViewModel empresa = null;

            if(Danfe.Model.TipoNF == 1)
            {
                empresa = Danfe.Model.Emitente;
            }
            else if(Danfe.Model.TipoNF == 0)
            {
                empresa = Danfe.Model.Destinatario;
            }
            else
            {
                throw new Exception("Tipo de NF não suportado.");
            }

            BlockComposer bComp = new BlockComposer(composer);

            composer.SafeDrawRectangle(RetNumeracao);
            composer.SafeDrawRectangle(RetRecebemos);

            composer.SetFont(Danfe.Font, 6);
            bComp.SafeBegin(RetRecebemos.GetPaddedRectangleMm(1), XAlignmentEnum.Left, YAlignmentEnum.Middle);
            bComp.ShowText(String.Format("RECEBEMOS DE {0} OS PRODUTOS E/OU SERVIÇOS CONSTANTES DA NOTA FISCAL ELETRÔNICA INDICADA ABAIXO.", empresa.Nome));
            bComp.End();

            // Numeração da NFe
            composer.SafeDrawRectangle(RetNumeracao);
            composer.SetFont(Danfe.FontBold, 12);
            bComp.SafeBegin(RetNumeracao, XAlignmentEnum.Center, YAlignmentEnum.Middle);
            bComp.ShowText(String.Format("NF-e\nNº {0}\nSérie {1}", Danfe.Model.NumeroNF.ToString(Formatador.FormatoNumeroNF), Danfe.Model.Serie));
            bComp.End();

            composer.Stroke();

            // Linha pontilhada
            composer.BeginLocalState();
            composer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));
            composer.DrawLine(new PointF(InternalRectangle.Left, Size.Height - MargemLinhaPontilhada), new PointF(InternalRectangle.Right, Size.Height - MargemLinhaPontilhada));
            composer.Stroke();
            composer.End();
        }
Exemplo n.º 14
0
        /*
         * TODO: refresh should happen just before serialization, on document event (e.g. OnWrite())
         */
        private void RefreshAppearance(
            )
        {
            FormXObject normalAppearance;
            RectangleF  box = org.pdfclown.objects.Rectangle.Wrap(BaseDataObject[PdfName.Rect]).ToRectangleF();
            {
                AppearanceStates normalAppearances = Appearance.Normal;
                normalAppearance = normalAppearances[null];
                if (normalAppearance != null)
                {
                    normalAppearance.Box = box;
                    normalAppearance.BaseDataObject.Body.SetLength(0);
                }
                else
                {
                    normalAppearances[null] = normalAppearance = new FormXObject(Document, box);
                }
            }

            PrimitiveComposer composer = new PrimitiveComposer(normalAppearance);

            {
                float          yOffset    = box.Height - Page.Box.Height;
                MarkupTypeEnum markupType = MarkupType;
                switch (markupType)
                {
                case MarkupTypeEnum.Highlight:
                {
                    ExtGState defaultExtGState;
                    {
                        ExtGStateResources extGStates = normalAppearance.Resources.ExtGStates;
                        defaultExtGState = extGStates[HighlightExtGStateName];
                        if (defaultExtGState == null)
                        {
                            if (extGStates.Count > 0)
                            {
                                extGStates.Clear();
                            }

                            extGStates[HighlightExtGStateName] = defaultExtGState = new ExtGState(Document);
                            defaultExtGState.AlphaShape        = false;
                            defaultExtGState.BlendMode         = new List <BlendModeEnum>(new BlendModeEnum[] { BlendModeEnum.Multiply });
                        }
                    }

                    composer.ApplyState(defaultExtGState);
                    composer.SetFillColor(Color);
                    {
                        foreach (Quad markupBox in MarkupBoxes)
                        {
                            PointF[] points          = markupBox.Points;
                            float    markupBoxHeight = points[3].Y - points[0].Y;
                            float    markupBoxMargin = GetMarkupBoxMargin(markupBoxHeight);
                            composer.DrawCurve(
                                new PointF(points[3].X, points[3].Y + yOffset),
                                new PointF(points[0].X, points[0].Y + yOffset),
                                new PointF(points[3].X - markupBoxMargin, points[3].Y - markupBoxMargin + yOffset),
                                new PointF(points[0].X - markupBoxMargin, points[0].Y + markupBoxMargin + yOffset)
                                );
                            composer.DrawLine(
                                new PointF(points[1].X, points[1].Y + yOffset)
                                );
                            composer.DrawCurve(
                                new PointF(points[2].X, points[2].Y + yOffset),
                                new PointF(points[1].X + markupBoxMargin, points[1].Y + markupBoxMargin + yOffset),
                                new PointF(points[2].X + markupBoxMargin, points[2].Y - markupBoxMargin + yOffset)
                                );
                            composer.Fill();
                        }
                    }
                }
                break;

                case MarkupTypeEnum.Squiggly:
                {
                    composer.SetStrokeColor(Color);
                    composer.SetLineCap(LineCapEnum.Round);
                    composer.SetLineJoin(LineJoinEnum.Round);
                    {
                        foreach (Quad markupBox in MarkupBoxes)
                        {
                            PointF[] points          = markupBox.Points;
                            float    markupBoxHeight = points[3].Y - points[0].Y;
                            float    lineWidth       = markupBoxHeight * .05f;
                            float    step            = markupBoxHeight * .125f;
                            float    boxXOffset      = points[3].X;
                            float    boxYOffset      = points[3].Y + yOffset - lineWidth;
                            bool     phase           = false;
                            composer.SetLineWidth(lineWidth);
                            for (float x = 0, xEnd = points[2].X - boxXOffset; x < xEnd || !phase; x += step)
                            {
                                PointF point = new PointF(x + boxXOffset, (phase ? -step : 0) + boxYOffset);
                                if (x == 0)
                                {
                                    composer.StartPath(point);
                                }
                                else
                                {
                                    composer.DrawLine(point);
                                }
                                phase = !phase;
                            }
                        }
                        composer.Stroke();
                    }
                }
                break;

                case MarkupTypeEnum.StrikeOut:
                case MarkupTypeEnum.Underline:
                {
                    composer.SetStrokeColor(Color);
                    {
                        float lineYRatio = 0;
                        switch (markupType)
                        {
                        case MarkupTypeEnum.StrikeOut:
                            lineYRatio = .5f;
                            break;

                        case MarkupTypeEnum.Underline:
                            lineYRatio = .9f;
                            break;

                        default:
                            throw new NotImplementedException();
                        }
                        foreach (Quad markupBox in MarkupBoxes)
                        {
                            PointF[] points          = markupBox.Points;
                            float    markupBoxHeight = points[3].Y - points[0].Y;
                            float    boxYOffset      = markupBoxHeight * lineYRatio + yOffset;
                            composer.SetLineWidth(markupBoxHeight * .065);
                            composer.DrawLine(
                                new PointF(points[3].X, points[0].Y + boxYOffset),
                                new PointF(points[2].X, points[1].Y + boxYOffset)
                                );
                        }
                        composer.Stroke();
                    }
                }
                break;

                default:
                    throw new NotImplementedException();
                }
            }
            composer.Flush();
        }
Exemplo n.º 15
0
        private void BuildMiscellaneousPage(
            Document document
            )
        {
            // 1. Add the page to the document!
              Page page = new Page(document); // Instantiates the page inside the document context.
              document.Pages.Add(page); // Puts the page in the pages collection.

              SizeF pageSize = page.Size;

              // 2. Create a content composer for the page!
              PrimitiveComposer composer = new PrimitiveComposer(page);

              // 3. Drawing the page contents...
              composer.SetFont(
            new fonts::StandardType1Font(
              document,
              fonts::StandardType1Font.FamilyEnum.Courier,
              true,
              false
              ),
            32
            );

              {
            BlockComposer blockComposer = new BlockComposer(composer);
            blockComposer.Begin(new RectangleF(30,0,pageSize.Width-60,50),XAlignmentEnum.Center,YAlignmentEnum.Middle);
            blockComposer.ShowText("Miscellaneous");
            blockComposer.End();
              }

              composer.BeginLocalState();
              composer.SetLineJoin(LineJoinEnum.Round);
              composer.SetLineCap(LineCapEnum.Round);

              // 3.1. Polygon.
              composer.DrawPolygon(
            new PointF[]
            {
              new PointF(100,200),
              new PointF(150,150),
              new PointF(200,150),
              new PointF(250,200)
            }
            );

              // 3.2. Polyline.
              composer.DrawPolyline(
            new PointF[]
            {
              new PointF(300,200),
              new PointF(350,150),
              new PointF(400,150),
              new PointF(450,200)
            }
            );

              composer.Stroke();

              // 3.3. Rectangle (both squared and rounded).
              int x = 50;
              int radius = 0;
              while(x < 500)
              {
            if(x > 300)
            {
              composer.SetLineDash(new LineDash(new double[]{5,5}, 3));
            }

            composer.SetFillColor(new DeviceRGBColor(1, x / 500d, x / 500d));
            composer.DrawRectangle(
              new RectangleF(x, 250, 150, 100),
              radius // NOTE: radius parameter determines the rounded angle size.
              );
            composer.FillStroke();

            x += 175;
            radius += 10;
              }
              composer.End(); // End local state.

              composer.BeginLocalState();
              composer.SetFont(
            composer.State.Font,
            12
            );

              // 3.4. Line cap parameter.
              int y = 400;
              foreach(LineCapEnum lineCap
            in (LineCapEnum[])Enum.GetValues(typeof(LineCapEnum)))
              {
            composer.ShowText(
              lineCap + ":",
              new PointF(50,y),
              XAlignmentEnum.Left,
              YAlignmentEnum.Middle,
              0
              );
            composer.SetLineWidth(12);
            composer.SetLineCap(lineCap);
            composer.DrawLine(
              new PointF(120,y),
              new PointF(220,y)
              );
            composer.Stroke();

            composer.BeginLocalState();
            composer.SetLineWidth(1);
            composer.SetStrokeColor(DeviceRGBColor.White);
            composer.SetLineCap(LineCapEnum.Butt);
            composer.DrawLine(
              new PointF(120,y),
              new PointF(220,y)
              );
            composer.Stroke();
            composer.End(); // End local state.

            y += 30;
              }

              // 3.5. Line join parameter.
              y += 50;
              foreach(LineJoinEnum lineJoin
            in (LineJoinEnum[])Enum.GetValues(typeof(LineJoinEnum)))
              {
            composer.ShowText(
              lineJoin + ":",
              new PointF(50,y),
              XAlignmentEnum.Left,
              YAlignmentEnum.Middle,
              0
              );
            composer.SetLineWidth(12);
            composer.SetLineJoin(lineJoin);
            PointF[] points = new PointF[]
              {
            new PointF(120,y+25),
            new PointF(150,y-25),
            new PointF(180,y+25)
              };
            composer.DrawPolyline(points);
            composer.Stroke();

            composer.BeginLocalState();
            composer.SetLineWidth(1);
            composer.SetStrokeColor(DeviceRGBColor.White);
            composer.SetLineCap(LineCapEnum.Butt);
            composer.DrawPolyline(points);
            composer.Stroke();
            composer.End(); // End local state.

            y += 50;
              }
              composer.End(); // End local state.

              // 3.6. Clipping.
              /*
            NOTE: Clipping should be conveniently enclosed within a local state
            in order to easily resume the unaltered drawing area after the operation completes.
              */
              composer.BeginLocalState();
              composer.DrawPolygon(
            new PointF[]
            {
              new PointF(220,410),
              new PointF(300,490),
              new PointF(450,360),
              new PointF(430,520),
              new PointF(590,565),
              new PointF(420,595),
              new PointF(460,730),
              new PointF(380,650),
              new PointF(330,765),
              new PointF(310,640),
              new PointF(220,710),
              new PointF(275,570),
              new PointF(170,500),
              new PointF(275,510)
            }
            );
              composer.Clip();
              // Showing a clown image...
              // Instantiate a jpeg image object!
              entities::Image image = entities::Image.Get(GetResourcePath("images" + System.IO.Path.DirectorySeparatorChar + "Clown.jpg")); // Abstract image (entity).
              xObjects::XObject imageXObject = image.ToXObject(document);
              // Show the image!
              composer.ShowXObject(
            imageXObject,
            new PointF(170, 320),
            GeomUtils.Scale(imageXObject.Size, new SizeF(450,0))
            );
              composer.End(); // End local state.

              // 4. Flush the contents into the page!
              composer.Flush();
        }
        /// <summary>
        /// Print as linhas tracejadas na tabela, ignorando a última
        /// </summary>
        /// <param name="composer"></param>
        /// <param name="y">Lista com as posições y</param>
        /// <param name="xBegin"></param>
        /// <param name="xEnd"></param>
        private void PrintLinhasTracejadas(PrimitiveComposer composer, List<float> y, float xBegin, float xEnd)
        {
            if (xBegin < 0)
            {
                throw new ArgumentOutOfRangeException("xBegin");
            }

            if (xEnd > composer.Scanner.CanvasSize.Width)
            {
                throw new ArgumentOutOfRangeException("xEnd");
            }

            composer.BeginLocalState();
            composer.SetLineDash(new LineDash(new Double[] { 3, 2 }));
            for (int i = 0; i < y.Count - 1; i++)
            {
                composer.DrawLine(new PointF(xBegin, y[i]), new PointF(xEnd, y[i]));
            }

            composer.Stroke();
            composer.End();
        }
        public TabelaProdutosServicosNFC(DanfeViewModel viewModel, Estilo estilo, PrimitiveComposer primitiveComposer, float y) : base(estilo)
        {
            if (y == 40)
            {
                Y_NFC = 100;
            }
            if (y == 50)
            {
                Y_NFC = 100 + 10;
            }

            primitiveComposer.BeginLocalState();
            primitiveComposer.SetFont(estilo.FonteCampoTituloNegrito.FonteInterna, estilo.FonteCampoTituloNegrito.Tamanho);
            primitiveComposer.ShowText("DOCUMENTO AUXILIAR DA NOTA FISCAL", new PointF(140, y + 10), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText("DE CONSUMIDOR ELETRÔNICA", new PointF(140, y + 20), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);

            primitiveComposer.DrawLine(new PointF(15, y + 30), new PointF(265, y + 30));
            primitiveComposer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));

            primitiveComposer.SetFont(estilo.FonteCampoConteudoNegrito.FonteInterna, estilo.FonteCampoConteudoNegrito.Tamanho);
            primitiveComposer.ShowText("DETALHE DA VENDA", new PointF(140, y + 40), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);

            primitiveComposer.DrawLine(new PointF(15, y + 50), new PointF(265, y + 50));
            primitiveComposer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));

            primitiveComposer.SetFont(estilo.FonteCampoConteudo.FonteInterna, estilo.FonteCampoConteudo.Tamanho);
            primitiveComposer.ShowText("CÓDIGO", new PointF(40, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText("DESC.", new PointF(80, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText("QTD.", new PointF(120, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText("UNID.", new PointF(160, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText("PREÇO", new PointF(200, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
            primitiveComposer.ShowText("TOTAL", new PointF(240, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);

            foreach (var produto in viewModel.Produtos)
            {
                Y_NFC = Y_NFC + 10;
                primitiveComposer.SetFont(estilo.FonteCampoConteudo.FonteInterna, estilo.FonteCampoConteudo.Tamanho);
                primitiveComposer.ShowText(produto.Codigo, new PointF(40, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);

                if (produto.Descricao.Length >= 10)
                {
                    primitiveComposer.ShowText(produto.Descricao.Substring(0, 10), new PointF(80, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
                }
                else
                {
                    primitiveComposer.ShowText(produto.Descricao, new PointF(80, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
                }

                primitiveComposer.ShowText(produto.Quantidade.Formatar(), new PointF(120, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
                primitiveComposer.ShowText(produto.Unidade, new PointF(160, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
                primitiveComposer.ShowText(produto.ValorUnitario.Formatar(), new PointF(200, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
                primitiveComposer.ShowText(produto.ValorTotal.Formatar(), new PointF(240, Y_NFC), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);
            }

            Y_NFC = Y_NFC + 10;

            primitiveComposer.DrawLine(new PointF(15, Y_NFC), new PointF(265, Y_NFC));
            primitiveComposer.SetLineDash(new org.pdfclown.documents.contents.LineDash(new double[] { 3, 2 }));
            primitiveComposer.Stroke();
            primitiveComposer.End();
        }
Exemplo n.º 18
0
        /*
          TODO: refresh should happen just before serialization, on document event (e.g. OnWrite())
        */
        private void RefreshAppearance(
      )
        {
            FormXObject normalAppearance;
              RectangleF box = org.pdfclown.objects.Rectangle.Wrap(BaseDataObject[PdfName.Rect]).ToRectangleF();
              {
            AppearanceStates normalAppearances = Appearance.Normal;
            normalAppearance = normalAppearances[null];
            if(normalAppearance != null)
            {
              normalAppearance.Box = box;
              normalAppearance.BaseDataObject.Body.SetLength(0);
            }
            else
            {normalAppearances[null] = normalAppearance = new FormXObject(Document, box);}
              }

              PrimitiveComposer composer = new PrimitiveComposer(normalAppearance);
              {
            float yOffset = box.Height - Page.Box.Height;
            MarkupTypeEnum markupType = MarkupType;
            switch(markupType)
            {
              case MarkupTypeEnum.Highlight:
              {
            ExtGState defaultExtGState;
            {
              ExtGStateResources extGStates = normalAppearance.Resources.ExtGStates;
              defaultExtGState = extGStates[HighlightExtGStateName];
              if(defaultExtGState == null)
              {
                if(extGStates.Count > 0)
                {extGStates.Clear();}

                extGStates[HighlightExtGStateName] = defaultExtGState = new ExtGState(Document);
                defaultExtGState.AlphaShape = false;
                defaultExtGState.BlendMode = new List<BlendModeEnum>(new BlendModeEnum[]{BlendModeEnum.Multiply});
              }
            }

            composer.ApplyState(defaultExtGState);
            composer.SetFillColor(Color);
            {
              foreach(Quad markupBox in MarkupBoxes)
              {
                PointF[] points = markupBox.Points;
                float markupBoxHeight = points[3].Y - points[0].Y;
                float markupBoxMargin = GetMarkupBoxMargin(markupBoxHeight);
                composer.DrawCurve(
                  new PointF(points[3].X, points[3].Y + yOffset),
                  new PointF(points[0].X, points[0].Y + yOffset),
                  new PointF(points[3].X - markupBoxMargin, points[3].Y - markupBoxMargin + yOffset),
                  new PointF(points[0].X - markupBoxMargin, points[0].Y + markupBoxMargin + yOffset)
                  );
                composer.DrawLine(
                  new PointF(points[1].X, points[1].Y + yOffset)
                  );
                composer.DrawCurve(
                  new PointF(points[2].X, points[2].Y + yOffset),
                  new PointF(points[1].X + markupBoxMargin, points[1].Y + markupBoxMargin + yOffset),
                  new PointF(points[2].X + markupBoxMargin, points[2].Y - markupBoxMargin + yOffset)
                  );
                composer.Fill();
              }
            }
              }
            break;
              case MarkupTypeEnum.Squiggly:
              {
            composer.SetStrokeColor(Color);
            composer.SetLineCap(LineCapEnum.Round);
            composer.SetLineJoin(LineJoinEnum.Round);
            {
              foreach(Quad markupBox in MarkupBoxes)
              {
                PointF[] points = markupBox.Points;
                float markupBoxHeight = points[3].Y - points[0].Y;
                float lineWidth = markupBoxHeight * .02f;
                float step = markupBoxHeight * .125f;
                float boxXOffset = points[3].X;
                float boxYOffset = points[3].Y + yOffset - lineWidth;
                bool phase = false;
                composer.SetLineWidth(lineWidth);
                for(float x = 0, xEnd = points[2].X - boxXOffset; x < xEnd || !phase; x += step)
                {
                  PointF point = new PointF(x + boxXOffset, (phase ? -step : 0) + boxYOffset);
                  if(x == 0)
                  {composer.StartPath(point);}
                  else
                  {composer.DrawLine(point);}
                  phase = !phase;
                }
              }
              composer.Stroke();
            }
              }
            break;
              case MarkupTypeEnum.StrikeOut:
              case MarkupTypeEnum.Underline:
              {
            composer.SetStrokeColor(Color);
            {
              float lineYRatio = 0;
              switch(markupType)
              {
                case MarkupTypeEnum.StrikeOut:
                  lineYRatio = .575f;
                  break;
                case MarkupTypeEnum.Underline:
                  lineYRatio = .85f;
                  break;
                default:
                  throw new NotImplementedException();
              }
              foreach(Quad markupBox in MarkupBoxes)
              {
                PointF[] points = markupBox.Points;
                float markupBoxHeight = points[3].Y - points[0].Y;
                float boxYOffset = markupBoxHeight * lineYRatio + yOffset;
                composer.SetLineWidth(markupBoxHeight * .065);
                composer.DrawLine(
                  new PointF(points[3].X, points[0].Y + boxYOffset),
                  new PointF(points[2].X, points[1].Y + boxYOffset)
                  );
              }
              composer.Stroke();
            }
              }
            break;
              default:
            throw new NotImplementedException();
            }
              }
              composer.Flush();
        }
        public FormXObject Build(
            )
        {
            bool   isRound         = type == TypeEnum.Round;
            bool   isStriped       = type == TypeEnum.Striped;
            double textScale       = .5;
            double borderWidth     = this.borderWidth.GetValue(width);
            double doubleBorderGap = borderDoubled ? borderWidth : 0;
            double fontSize        = 10;

            fontSize *= ((width - (isStriped ? 2 : doubleBorderGap * 2 + (borderWidth * (borderDoubled ? 1.5 : 1) * 2) + width * (isRound ?  .15 : .05))) / textScale) / font.GetWidth(text, fontSize);
            float height = (float)(isRound ? width : (font.GetAscent(fontSize) * 1.2 + doubleBorderGap * 2 + (borderWidth * (borderDoubled ? 1.5 : 1) * 2)));
            SizeF size   = new SizeF(width, height);

            FormXObject appearance = new FormXObject(document, size);

            {
                PrimitiveComposer composer = new PrimitiveComposer(appearance);
                if (color != null)
                {
                    composer.SetStrokeColor(color);
                    composer.SetFillColor(color);
                }
                composer.SetTextScale(textScale);
                composer.SetFont(font, fontSize);
                composer.ShowText(text, new PointF(size.Width / 2, (float)(size.Height / 2 - font.GetDescent(fontSize) * .4)), XAlignmentEnum.Center, YAlignmentEnum.Middle, 0);

                double     borderRadius  = isRound ? 0 : this.borderRadius.GetValue((size.Width + size.Height) / 2);
                RectangleF prevBorderBox = appearance.Box;
                for (int borderStep = 0, borderStepLimit = (borderDoubled ? 2 : 1); borderStep < borderStepLimit; borderStep++)
                {
                    if (borderStep == 0)
                    {
                        composer.SetLineWidth(borderWidth);
                    }
                    else
                    {
                        composer.SetLineWidth(composer.State.LineWidth / 2);
                    }

                    float      lineWidth = (float)(borderStep > 0 ? composer.State.LineWidth / 2 : borderWidth);
                    float      marginY   = (float)(lineWidth / 2 + (borderStep > 0 ? composer.State.LineWidth + doubleBorderGap : 0));
                    float      marginX   = isStriped ? 0 : marginY;
                    RectangleF borderBox = new RectangleF(prevBorderBox.X + marginX, prevBorderBox.Y + marginY, prevBorderBox.Width - marginX * 2, prevBorderBox.Height - marginY * 2);

                    if (isRound)
                    {
                        composer.DrawEllipse(borderBox);
                    }
                    else
                    {
                        if (isStriped)
                        {
                            composer.DrawLine(new PointF(borderBox.Left, borderBox.Top), new PointF(borderBox.Right, borderBox.Top));
                            composer.DrawLine(new PointF(borderBox.Left, borderBox.Bottom), new PointF(borderBox.Right, borderBox.Bottom));
                        }
                        else
                        {
                            composer.DrawRectangle(borderBox, borderRadius * (1 - .5 * borderStep));
                        }
                    }
                    composer.Stroke();
                    prevBorderBox = borderBox;
                }
                composer.Flush();
            }
            return(appearance);
        }