コード例 #1
0
        private void PrintDescricaoDanfe(RectangleF area, BlockComposer bComp, PrimitiveComposer comp)
        {
            comp.SafeDrawRectangle(area);

            // Retangulo com padding
            RectangleF pRet = area.GetPaddedRectangleMm(1);

            // DANFE e descrição
            bComp.SafeBegin(pRet, XAlignmentEnum.Center, YAlignmentEnum.Top);
            comp.SetFont(Danfe.FontBold, 12);
            bComp.ShowText("DANFE");
            comp.SetFont(Danfe.Font, 6);
            bComp.ShowBreak(new SizeF(0, 1));
            bComp.ShowText(DescricaoDanfe);
            bComp.End();

            // Entrada, Saída
            RectangleF rEntrasaSaida = new RectangleF(pRet.X, bComp.BoundBox.Bottom + Utils.Mm2Pu(1.5F), pRet.Width, pRet.Bottom - bComp.BoundBox.Bottom);

            rEntrasaSaida = rEntrasaSaida.GetPaddedRectangleMm(0, 2.5F);

            comp.SetFont(Danfe.Font, 8);
            bComp.SafeBegin(rEntrasaSaida, XAlignmentEnum.Left, YAlignmentEnum.Top);
            bComp.ShowText("0 - Entrada\n1 - Saída");
            bComp.End();

            RectangleF rEntrasaSaida2 = bComp.BoundBox;

            rEntrasaSaida2 = new RectangleF(rEntrasaSaida.Right - bComp.BoundBox.Height, bComp.BoundBox.Y, bComp.BoundBox.Height, bComp.BoundBox.Height);
            comp.SafeDrawRectangle(rEntrasaSaida2);

            bComp.SafeBegin(rEntrasaSaida2, XAlignmentEnum.Center, YAlignmentEnum.Middle);
            bComp.ShowText(Danfe.Model.TipoNF.ToString());
            bComp.End();



            // Número Série e Folha
            RectangleF retEsquerdo = pRet;

            retEsquerdo.Width = Utils.Mm2Pu(8);

            RectangleF retDireito = pRet;

            retDireito.X     = retEsquerdo.Right + Utils.Mm2Pu(1);
            retDireito.Width = pRet.Right - retDireito.Left;

            RetanguloFolha     = retDireito;
            retDireito.Height -= (float)Danfe.FontBold.GetLineHeight(TamanhoFonteNumeracao);

            comp.SetFont(Danfe.FontBold, TamanhoFonteNumeracao);
            bComp.SafeBegin(retEsquerdo, XAlignmentEnum.Right, YAlignmentEnum.Bottom);
            bComp.ShowText("Nº\nSérie\nFolha");
            bComp.End();

            bComp.SafeBegin(retDireito, XAlignmentEnum.Left, YAlignmentEnum.Bottom);
            bComp.ShowText(String.Format("{0}\n{1}", Danfe.Model.NumeroNF.ToString(Formatador.FormatoNumeroNF), Danfe.Model.Serie));
            bComp.End();
        }
コード例 #2
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();
        }
コード例 #3
0
        protected override void ToXObjectInternal(PrimitiveComposer comp)
        {
            BlockComposer bComp = new BlockComposer(comp);

            PrintIdentificacaoEmitente(RetEmitente, bComp, comp);
            PrintDescricaoDanfe(RetDescDanfe, bComp, comp);

            var emitente = Danfe.Model.Emitente;

            comp.SafeDrawRectangle(RetCodigoBarras);
            comp.SafeDrawRectangle(RetCampoVariavel);

            comp.SetFont(Danfe.Font, 8);
            bComp.SafeBegin(RetCampoVariavel, XAlignmentEnum.Center, YAlignmentEnum.Middle);
            bComp.ShowText(MensagemConsulta);
            bComp.End();

            comp.Stroke();

            var barcode = new Barcode128C(Danfe.Model.ChaveAcesso, RetCodigoBarras.Size).ToXObject(Danfe.Document);

            comp.ShowXObject(barcode, new PointF(RetCodigoBarras.X, RetCodigoBarras.Y));
        }
コード例 #4
0
        public void PrintCabecalhos(PrimitiveComposer composer)
        {
            BlockComposer bComp = new BlockComposer(composer);
            composer.SetFont(_Documento.FontBold, 5);

            for (int i = 0; i < _Colunas.Length; i++)
            {
                RectangleF r = _Colunas[i].Retangulo;
                r.Height = AlturaCabecalhoTabela;
                bComp.SafeBegin(r.GetPaddedRectangle(Margem), _Colunas[i].AlinhamentoHorizontal, YAlignmentEnum.Middle);
                bComp.ShowText(_Colunas[i].Cabecalho.ToUpper());
                bComp.End();

                composer.SafeDrawRectangle(r);
            }
        }
コード例 #5
0
        protected override void ToXObjectInternal(PrimitiveComposer comp)
        {
            var duplicatas = Danfe.Model.Duplicatas;

            BlockComposer bComp = new BlockComposer(comp);

            RectangleF r1 = InternalRectangle;

            r1.Height = RetanguloH;

            RectangleF[] colunas     = r1.SplitRectangle(Colunas);
            int          colunaIndex = 0;


            for (int i = 0; i < duplicatas.Count; i++)
            {
                if (i > 0 && i % Colunas == 0)
                {
                    colunaIndex = 0;

                    for (int i2 = 0; i2 < Colunas; i2++)
                    {
                        colunas[i2].Y += RetanguloH;
                    }
                }

                var        duplicata = duplicatas[i];
                RectangleF pRet      = colunas[colunaIndex].GetPaddedRectangleMm(1);
                comp.SetFont(Danfe.Font, 6);
                bComp.SafeBegin(pRet, XAlignmentEnum.Left, YAlignmentEnum.Middle);
                bComp.ShowText("Número:\nVenc.:\nValor:\n");
                bComp.End();


                comp.SetFont(Danfe.FontBold, 6);

                bComp.SafeBegin(pRet, XAlignmentEnum.Right, YAlignmentEnum.Middle);
                bComp.ShowText(String.Format("{0}\n{1}\n{2}\n", duplicata.Numero, duplicata.Vecimento.Formatar(), duplicata.Valor.Formatar()));
                bComp.End();

                comp.SafeDrawRectangle(colunas[colunaIndex]);

                colunaIndex++;
            }

            comp.Stroke();
        }
コード例 #6
0
        public void PrintCabecalhos(PrimitiveComposer composer)
        {
            BlockComposer bComp = new BlockComposer(composer);

            composer.SetFont(_Documento.FontBold, 5);

            for (int i = 0; i < _Colunas.Length; i++)
            {
                RectangleF r = _Colunas[i].Retangulo;
                r.Height = AlturaCabecalhoTabela;
                bComp.SafeBegin(r.GetPaddedRectangle(Margem), _Colunas[i].AlinhamentoHorizontal, YAlignmentEnum.Middle);
                bComp.ShowText(_Colunas[i].Cabecalho.ToUpper());
                bComp.End();

                composer.SafeDrawRectangle(r);
            }
        }
コード例 #7
0
ファイル: DanfeCampo.cs プロジェクト: victorpothin/DanfeSharp
        /// <summary>
        /// Imprime o campo no composer.
        /// </summary>
        /// <param name="comp"></param>
        public void Print(PrimitiveComposer comp, org.pdfclown.documents.contents.fonts.Font fonte, org.pdfclown.documents.contents.fonts.Font fonteBold)
        {
            BlockComposer bComp = new BlockComposer(comp);
            RectangleF    pRect = Retangulo.GetPaddedRectangle(PaddingHorizontal, PaddingHorizontal, PaddingSuperior, PaddingInferior);

            comp.SetFont(fonteBold, TamanhoFonteCabecalho);
            ValidadeRectangle(pRect, comp);
            bComp.SafeBegin(pRect, XAlignmentEnum.Left, YAlignmentEnum.Top);
            bComp.ShowText(Cabecalho.ToUpper());
            bComp.End();

            bComp.LineSpace = new Length(LineSpace, Length.UnitModeEnum.Absolute);

            if (!String.IsNullOrWhiteSpace(Corpo))
            {
                org.pdfclown.documents.contents.fonts.Font fonteCorpo = IsCorpoNegrito ? fonteBold : fonte;

                double largura     = fonteCorpo.GetWidth(Corpo, CorpoTamanhoFonte);
                double novoTamanho = CorpoTamanhoFonte;

                if (!MultiLinha && largura > pRect.Width)
                {
                    novoTamanho = (CorpoTamanhoFonte * pRect.Width) / largura - Utils.Mm2Pu(0.005F);
                    comp.SetFont(fonteCorpo, novoTamanho);
                }

                comp.SetFont(fonteCorpo, novoTamanho);

                if (CorpoAlinhamentoY == YAlignmentEnum.Top)
                {
                    float yOffSet = (float)fonteBold.GetLineHeight(TamanhoFonteCabecalho) + LineSpace;
                    pRect.Y      += yOffSet;
                    pRect.Height -= yOffSet;
                }

                ValidadeRectangle(pRect, comp);
                bComp.SafeBegin(pRect, CorpoAlinhamentoX, CorpoAlinhamentoY);
                bComp.ShowText(Corpo);
                bComp.End();
            }

            comp.SafeDrawRectangle(Retangulo);
        }
コード例 #8
0
        private void PrintIdentificacaoEmitente(RectangleF area, BlockComposer bComp, PrimitiveComposer comp)
        {
            comp.SafeDrawRectangle(area);

            // Retângulo com padding
            RectangleF pRet = area.GetPaddedRectangleMm(1);

            var emitente = Danfe.Model.Emitente;

            var yAlign = Danfe.PossuiLogo ? YAlignmentEnum.Bottom : YAlignmentEnum.Middle;

            bComp.SafeBegin(pRet, XAlignmentEnum.Left, yAlign);

            double bestSize = DanfeCampo.AjustarFonte(emitente.Nome, Danfe.FontBold, pRet.Width, Danfe.PossuiLogo ? 10 : 12);

            comp.SetFont(Danfe.FontBold, bestSize);

            bComp.ShowText(emitente.Nome);
            bComp.ShowBreak();
            comp.SetFont(Danfe.Font, Danfe.PossuiLogo ? 7 : 8);
            bComp.ShowText(emitente.EnderecoLinha1);
            bComp.ShowBreak();
            bComp.ShowText(emitente.EnderecoBairro);
            bComp.ShowBreak();
            bComp.ShowText(emitente.EnderecoLinha3);

            if (!String.IsNullOrWhiteSpace(emitente.Telefone))
            {
                bComp.ShowBreak();
                bComp.ShowText(String.Format("Fone: {0}", Formatador.FormatarTelefone(emitente.Telefone)));
            }

            bComp.End();

            if (Danfe.PossuiLogo)
            {
                RectangleF logoRectangle = area;
                logoRectangle.Height = bComp.BoundBox.Top - logoRectangle.Y;
                PrintLogo(comp, logoRectangle);
            }
        }
コード例 #9
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();
        }
コード例 #10
0
        internal int PrintTable(PrimitiveComposer composer, RectangleF tableArea, int lInit = 0)
        {
            _Colunas[1].Largura = tableArea.Width - _Colunas.Sum(x => x.Largura);
            _Colunas[0].Retangulo = new RectangleF(tableArea.Left, tableArea.Top, _Colunas[0].Largura, tableArea.Height - AlturaCabecalhoTabela);

            for (int i = 1; i < _Colunas.Length; i++)
            {
                RectangleF r = _Colunas[i - 1].Retangulo;
                r.Width = _Colunas[i].Largura;
                r.X = _Colunas[i - 1].Retangulo.Right;
                _Colunas[i].Retangulo = r;
            }

            PrintCabecalhos(composer);

            composer.SetFont(_Documento.Font, 6);

            // Retângulos com padding
            var pr = _Colunas.Select(x => x.Retangulo).ToArray();

            for (int i = 0; i < _Colunas.Length; i++)
            {

                pr[i].Y += AlturaCabecalhoTabela + Margem;
                pr[i].Height -= AlturaCabecalhoTabela + 2 * Margem;
                pr[i].Width -= 2 * Margem;
                pr[i].X += Margem;
            }

            composer.Stroke();

            List<float> dashedLinesY = new List<float>();

            int l = lInit;
            for (; l < Valores.GetLength(0); l++)
            {

                if (!RowFit(l, pr) || CurrentY >= tableArea.Bottom || pr[0].Height <= 0 || ((_Documento.Font.GetLineHeight(6) + Margem) > pr[0].Height))
                {
                    break;
                }

                for (int c = 0; c < _Colunas.Length; c++)
                {
                    PrintTextCell(composer, Valores[l, c], pr[c], _Colunas[c].AlinhamentoHorizontal);
                }

                for (int c = 0; c < _Colunas.Length; c++)
                {
                    pr[c].Y = CurrentY + 2 * Margem;
                    pr[c].Height = tableArea.Bottom - pr[c].Y;
                }

                dashedLinesY.Add(CurrentY + Margem);

            }

            PrintLinhasTracejadas(composer, dashedLinesY, tableArea.Left, tableArea.Right);

            for (int i = 0; i < _Colunas.Length; i++)
            {
                RectangleF rct = _Colunas[i].Retangulo;
                rct.Height = CurrentY + Margem - _Colunas[i].Retangulo.Top;
                _Colunas[i].Retangulo = rct;
                composer.SafeDrawRectangle(_Colunas[i].Retangulo);
            }

            return l;
        }
コード例 #11
0
        protected override void ToXObjectInternal(PrimitiveComposer comp)
        {
            var duplicatas = Danfe.Model.Duplicatas;

            BlockComposer bComp = new BlockComposer(comp);

            RectangleF r1 = InternalRectangle;
            r1.Height = RetanguloH;

            RectangleF[] colunas = r1.SplitRectangle(Colunas);
            int colunaIndex = 0;

            for (int i = 0; i < duplicatas.Count; i++)
            {

                if (i > 0 && i % Colunas == 0)
                {
                    colunaIndex = 0;

                    for (int i2 = 0; i2 < Colunas; i2++)
                    {
                        colunas[i2].Y += RetanguloH;
                    }
                }

                var duplicata = duplicatas[i];
                RectangleF pRet = colunas[colunaIndex].GetPaddedRectangleMm(1);
                comp.SetFont(Danfe.Font, 6);
                bComp.SafeBegin(pRet, XAlignmentEnum.Left, YAlignmentEnum.Middle);
                bComp.ShowText("Número:\nVenc.:\nValor:\n");
                bComp.End();

                comp.SetFont(Danfe.FontBold, 6);

                bComp.SafeBegin(pRet, XAlignmentEnum.Right, YAlignmentEnum.Middle);
                bComp.ShowText(String.Format("{0}\n{1}\n{2}\n", duplicata.Numero, duplicata.Vecimento.Formatar(), duplicata.Valor.Formatar()));
                bComp.End();

                comp.SafeDrawRectangle(colunas[colunaIndex]);

                colunaIndex++;
            }

            comp.Stroke();
        }
コード例 #12
0
ファイル: DanfeCampo.cs プロジェクト: josuecorrea/DanfeSharp
        /// <summary>
        /// Imprime o campo no composer.
        /// </summary>
        /// <param name="comp"></param>
        public void Print(PrimitiveComposer comp, org.pdfclown.documents.contents.fonts.Font fonte, org.pdfclown.documents.contents.fonts.Font fonteBold)
        {
            BlockComposer bComp = new BlockComposer(comp);
            RectangleF pRect = Retangulo.GetPaddedRectangle(PaddingHorizontal, PaddingHorizontal, PaddingSuperior, PaddingInferior);

            comp.SetFont(fonteBold, TamanhoFonteCabecalho);
            ValidadeRectangle(pRect, comp);
            bComp.SafeBegin(pRect, XAlignmentEnum.Left, YAlignmentEnum.Top);
            bComp.ShowText(Cabecalho.ToUpper());
            bComp.End();

            bComp.LineSpace = new Length(LineSpace, Length.UnitModeEnum.Absolute);

            if (!String.IsNullOrWhiteSpace(Corpo))
            {
                org.pdfclown.documents.contents.fonts.Font fonteCorpo = IsCorpoNegrito ? fonteBold : fonte;

                double largura = fonteCorpo.GetWidth(Corpo, CorpoTamanhoFonte);
                double novoTamanho = CorpoTamanhoFonte;

                if (!MultiLinha && largura > pRect.Width)
                {
                    novoTamanho = (CorpoTamanhoFonte * pRect.Width) / largura - Utils.Mm2Pu(0.005F);
                    comp.SetFont(fonteCorpo, novoTamanho);
                }

                comp.SetFont(fonteCorpo, novoTamanho);

                if (CorpoAlinhamentoY == YAlignmentEnum.Top)
                {
                    float yOffSet = (float)fonteBold.GetLineHeight(TamanhoFonteCabecalho) + LineSpace;
                    pRect.Y += yOffSet;
                    pRect.Height -= yOffSet;
                }

                ValidadeRectangle(pRect, comp);
                bComp.SafeBegin(pRect, CorpoAlinhamentoX, CorpoAlinhamentoY);
                bComp.ShowText(Corpo);
                bComp.End();
            }

            comp.SafeDrawRectangle(Retangulo);
        }
コード例 #13
0
        private void PrintIdentificacaoEmitente(RectangleF area, BlockComposer bComp, PrimitiveComposer comp)
        {
            comp.SafeDrawRectangle(area);

            // Retângulo com padding
            RectangleF pRet = area.GetPaddedRectangleMm(1);

            var emitente = Danfe.Model.Emitente;

            var yAlign = Danfe.PossuiLogo ? YAlignmentEnum.Bottom : YAlignmentEnum.Middle;

            bComp.SafeBegin(pRet, XAlignmentEnum.Left, yAlign);

            double bestSize = DanfeCampo.AjustarFonte(emitente.Nome, Danfe.FontBold, pRet.Width, Danfe.PossuiLogo ? 10 : 12);
            comp.SetFont(Danfe.FontBold, bestSize);

            bComp.ShowText(emitente.Nome);
            bComp.ShowBreak();
            comp.SetFont(Danfe.Font, Danfe.PossuiLogo ? 7 : 8);
            bComp.ShowText(emitente.EnderecoLinha1);
            bComp.ShowBreak();
            bComp.ShowText(emitente.EnderecoBairro);
            bComp.ShowBreak();
            bComp.ShowText(emitente.EnderecoLinha3);

            if (!String.IsNullOrWhiteSpace(emitente.Telefone))
            {
                bComp.ShowBreak();
                bComp.ShowText(String.Format("Fone: {0}", Formatador.FormatarTelefone(emitente.Telefone)));
            }

            bComp.End();

            if (Danfe.PossuiLogo)
            {
                RectangleF logoRectangle = area;
                logoRectangle.Height = bComp.BoundBox.Top - logoRectangle.Y;
                PrintLogo(comp, logoRectangle);
            }
        }
コード例 #14
0
        private void PrintDescricaoDanfe(RectangleF area, BlockComposer bComp, PrimitiveComposer comp)
        {
            comp.SafeDrawRectangle(area);

            // Retangulo com padding
            RectangleF pRet = area.GetPaddedRectangleMm(1);

            // DANFE e descrição
            bComp.SafeBegin(pRet, XAlignmentEnum.Center, YAlignmentEnum.Top);
            comp.SetFont(Danfe.FontBold, 12);
            bComp.ShowText("DANFE");
            comp.SetFont(Danfe.Font, 6);
            bComp.ShowBreak(new SizeF(0, 1));
            bComp.ShowText(DescricaoDanfe);
            bComp.End();

            // Entrada, Saída
            RectangleF rEntrasaSaida = new RectangleF(pRet.X, bComp.BoundBox.Bottom + Utils.Mm2Pu(1.5F), pRet.Width, pRet.Bottom - bComp.BoundBox.Bottom);
            rEntrasaSaida = rEntrasaSaida.GetPaddedRectangleMm(0, 2.5F);

            comp.SetFont(Danfe.Font, 8);
            bComp.SafeBegin(rEntrasaSaida, XAlignmentEnum.Left, YAlignmentEnum.Top);
            bComp.ShowText("0 - Entrada\n1 - Saída");
            bComp.End();

            RectangleF rEntrasaSaida2 = bComp.BoundBox;
            rEntrasaSaida2 = new RectangleF(rEntrasaSaida.Right - bComp.BoundBox.Height, bComp.BoundBox.Y, bComp.BoundBox.Height, bComp.BoundBox.Height);
            comp.SafeDrawRectangle(rEntrasaSaida2);

            bComp.SafeBegin(rEntrasaSaida2, XAlignmentEnum.Center, YAlignmentEnum.Middle);
            bComp.ShowText(Danfe.Model.TipoNF.ToString());
            bComp.End();

            // Número Série e Folha
            RectangleF retEsquerdo = pRet;
            retEsquerdo.Width = Utils.Mm2Pu(8);

            RectangleF retDireito = pRet;
            retDireito.X = retEsquerdo.Right + Utils.Mm2Pu(1);
            retDireito.Width = pRet.Right - retDireito.Left;

            RetanguloFolha = retDireito;
            retDireito.Height -= (float)Danfe.FontBold.GetLineHeight(TamanhoFonteNumeracao);

            comp.SetFont(Danfe.FontBold, TamanhoFonteNumeracao);
            bComp.SafeBegin(retEsquerdo, XAlignmentEnum.Right, YAlignmentEnum.Bottom);
            bComp.ShowText("Nº\nSérie\nFolha");
            bComp.End();

            bComp.SafeBegin(retDireito, XAlignmentEnum.Left, YAlignmentEnum.Bottom);
            bComp.ShowText(String.Format("{0}\n{1}", Danfe.Model.NumeroNF.ToString(Formatador.FormatoNumeroNF), Danfe.Model.Serie));
            bComp.End();
        }
コード例 #15
0
        protected override void ToXObjectInternal(PrimitiveComposer comp)
        {
            BlockComposer bComp = new BlockComposer(comp);

            PrintIdentificacaoEmitente(RetEmitente, bComp, comp);
            PrintDescricaoDanfe(RetDescDanfe, bComp, comp);

            var emitente = Danfe.Model.Emitente;

            comp.SafeDrawRectangle(RetCodigoBarras);
            comp.SafeDrawRectangle(RetCampoVariavel);

            comp.SetFont(Danfe.Font, 8);
            bComp.SafeBegin(RetCampoVariavel, XAlignmentEnum.Center, YAlignmentEnum.Middle);
            bComp.ShowText(MensagemConsulta);
            bComp.End();

            comp.Stroke();

            var barcode = new Barcode128C(Danfe.Model.ChaveAcesso, RetCodigoBarras.Size).ToXObject(Danfe.Document);
            comp.ShowXObject(barcode, new PointF(RetCodigoBarras.X, RetCodigoBarras.Y));
        }
コード例 #16
0
        internal int PrintTable(PrimitiveComposer composer, RectangleF tableArea, int lInit = 0)
        {
            _Colunas[1].Largura   = tableArea.Width - _Colunas.Sum(x => x.Largura);
            _Colunas[0].Retangulo = new RectangleF(tableArea.Left, tableArea.Top, _Colunas[0].Largura, tableArea.Height - AlturaCabecalhoTabela);


            for (int i = 1; i < _Colunas.Length; i++)
            {
                RectangleF r = _Colunas[i - 1].Retangulo;
                r.Width = _Colunas[i].Largura;
                r.X     = _Colunas[i - 1].Retangulo.Right;
                _Colunas[i].Retangulo = r;
            }

            PrintCabecalhos(composer);

            composer.SetFont(_Documento.Font, 6);

            // Retângulos com padding
            var pr = _Colunas.Select(x => x.Retangulo).ToArray();

            for (int i = 0; i < _Colunas.Length; i++)
            {
                pr[i].Y      += AlturaCabecalhoTabela + Margem;
                pr[i].Height -= AlturaCabecalhoTabela + 2 * Margem;
                pr[i].Width  -= 2 * Margem;
                pr[i].X      += Margem;
            }

            composer.Stroke();

            List <float> dashedLinesY = new List <float>();

            int l = lInit;

            for (; l < Valores.GetLength(0); l++)
            {
                if (!RowFit(l, pr) || CurrentY >= tableArea.Bottom || pr[0].Height <= 0 || ((_Documento.Font.GetLineHeight(6) + Margem) > pr[0].Height))
                {
                    break;
                }


                for (int c = 0; c < _Colunas.Length; c++)
                {
                    PrintTextCell(composer, Valores[l, c], pr[c], _Colunas[c].AlinhamentoHorizontal);
                }

                for (int c = 0; c < _Colunas.Length; c++)
                {
                    pr[c].Y      = CurrentY + 2 * Margem;
                    pr[c].Height = tableArea.Bottom - pr[c].Y;
                }

                dashedLinesY.Add(CurrentY + Margem);
            }

            PrintLinhasTracejadas(composer, dashedLinesY, tableArea.Left, tableArea.Right);

            for (int i = 0; i < _Colunas.Length; i++)
            {
                RectangleF rct = _Colunas[i].Retangulo;
                rct.Height            = CurrentY + Margem - _Colunas[i].Retangulo.Top;
                _Colunas[i].Retangulo = rct;
                composer.SafeDrawRectangle(_Colunas[i].Retangulo);
            }

            return(l);
        }