Exemple #1
0
        private void PrintDescricaoDanfe(RectangleF area, org.pdfclown.documents.contents.composition.BlockComposer bComp, org.pdfclown.documents.contents.composition.PrimitiveComposer comp)
        {
            comp.SafeDrawRectangle(area);

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

            // DANFE e descrição
            bComp.SafeBegin(pRet, org.pdfclown.documents.contents.composition.XAlignmentEnum.Center, org.pdfclown.documents.contents.composition.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, org.pdfclown.documents.contents.composition.XAlignmentEnum.Left, org.pdfclown.documents.contents.composition.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, org.pdfclown.documents.contents.composition.XAlignmentEnum.Center, org.pdfclown.documents.contents.composition.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, org.pdfclown.documents.contents.composition.XAlignmentEnum.Right, org.pdfclown.documents.contents.composition.YAlignmentEnum.Bottom);
            bComp.ShowText("Nº\nSérie\nFolha");
            bComp.End();

            bComp.SafeBegin(retDireito, org.pdfclown.documents.contents.composition.XAlignmentEnum.Left, org.pdfclown.documents.contents.composition.YAlignmentEnum.Bottom);
            bComp.ShowText(string.Format("{0}\n{1}", Danfe.Model.NumeroNF.ToString(Formatador.FormatoNumeroNF), Danfe.Model.Serie));
            bComp.End();
        }
Exemple #2
0
        protected override void ToXObjectInternal(org.pdfclown.documents.contents.composition.PrimitiveComposer comp)
        {
            var duplicatas = Danfe.Model.Duplicatas;

            org.pdfclown.documents.contents.composition.BlockComposer bComp = new org.pdfclown.documents.contents.composition.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, org.pdfclown.documents.contents.composition.XAlignmentEnum.Left, org.pdfclown.documents.contents.composition.YAlignmentEnum.Middle);
                bComp.ShowText("Número:\nVenc.:\nValor:\n");
                bComp.End();

                comp.SetFont(Danfe.FontBold, 6);

                bComp.SafeBegin(pRet, org.pdfclown.documents.contents.composition.XAlignmentEnum.Right, org.pdfclown.documents.contents.composition.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();
        }
Exemple #3
0
        protected override void ToXObjectInternal(org.pdfclown.documents.contents.composition.PrimitiveComposer composer)
        {
            EmpresaViewModel empresa;

            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.");
            }

            org.pdfclown.documents.contents.composition.BlockComposer bComp = new org.pdfclown.documents.contents.composition.BlockComposer(composer);

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

            composer.SetFont(Danfe.Font, 6);
            bComp.SafeBegin(RetRecebemos.GetPaddedRectangleMm(1), org.pdfclown.documents.contents.composition.XAlignmentEnum.Left, org.pdfclown.documents.contents.composition.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, org.pdfclown.documents.contents.composition.XAlignmentEnum.Center, org.pdfclown.documents.contents.composition.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();
        }
Exemple #4
0
        /// <summary>
        /// Imprime o campo no composer.
        /// </summary>
        /// <param name="comp"></param>
        public void Print(org.pdfclown.documents.contents.composition.PrimitiveComposer comp, org.pdfclown.documents.contents.fonts.Font fonte, org.pdfclown.documents.contents.fonts.Font fonteBold)
        {
            org.pdfclown.documents.contents.composition.BlockComposer bComp = new org.pdfclown.documents.contents.composition.BlockComposer(comp);
            RectangleF pRect = Retangulo.GetPaddedRectangle(PaddingHorizontal, PaddingHorizontal, PaddingSuperior, PaddingInferior);

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

            bComp.LineSpace = new org.pdfclown.documents.contents.composition.Length(LineSpace, org.pdfclown.documents.contents.composition.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 == org.pdfclown.documents.contents.composition.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);
        }
Exemple #5
0
        private void PrintIdentificacaoEmitente(RectangleF area, org.pdfclown.documents.contents.composition.BlockComposer bComp, org.pdfclown.documents.contents.composition.PrimitiveComposer comp)
        {
            comp.SafeDrawRectangle(area);

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

            var emitente = Danfe.Model.Emitente;

            var yAlign = Danfe.PossuiLogo ? org.pdfclown.documents.contents.composition.YAlignmentEnum.Bottom : org.pdfclown.documents.contents.composition.YAlignmentEnum.Middle;

            bComp.SafeBegin(pRet, org.pdfclown.documents.contents.composition.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);
            }
        }
Exemple #6
0
        private void PrintMarcaDAgua(string text)
        {
            PointF p = PointF.Empty;

            var blocoProdutos = BlocosSuperiores.FirstOrDefault(x => x is BlocoProdutos);

            if (blocoProdutos == null)
            {
                p = new PointF(_Danfe.Size.Width / 2f, _Danfe.Size.Height / 2f);
            }
            else
            {
                p.X = blocoProdutos.Posicao.X + blocoProdutos.Size.Width / 2F;
                p.Y = blocoProdutos.Posicao.Y + blocoProdutos.Size.Height / 2F;
            }

            _Composer.BeginLocalState();
            _Composer.SetFont(_Danfe.FontBold, 50);
            org.pdfclown.documents.contents.ExtGState state = new org.pdfclown.documents.contents.ExtGState(_Danfe.Document);
            state.FillAlpha = 0.3F;
            _Composer.ApplyState(state);
            _Composer.ShowText(text, p, org.pdfclown.documents.contents.composition.XAlignmentEnum.Center, org.pdfclown.documents.contents.composition.YAlignmentEnum.Middle, 0);
            _Composer.End();
        }
Exemple #7
0
        /// <summary>
        /// Imprime o cabeçalho do bloco.
        /// </summary>
        private void PrintCabecalho(org.pdfclown.documents.contents.composition.PrimitiveComposer comp)
        {
            org.pdfclown.documents.contents.composition.BlockComposer bComp = new org.pdfclown.documents.contents.composition.BlockComposer(comp);

            RectangleF rect = new RectangleF(0, 0, Size.Width, Danfe.CabecalhoBlocoAltura);

            rect = rect.GetPaddedRectangleMm(0, 0, 1, 0.3F);

            comp.SetFont(Danfe.FontBold, 5);
            bComp.SafeBegin(rect, org.pdfclown.documents.contents.composition.XAlignmentEnum.Left, org.pdfclown.documents.contents.composition.YAlignmentEnum.Bottom);
            bComp.ShowText(Cabecalho.ToUpper());
            bComp.End();

            comp.Flush();
        }
Exemple #8
0
        public void PrintCabecalhos(org.pdfclown.documents.contents.composition.PrimitiveComposer composer)
        {
            org.pdfclown.documents.contents.composition.BlockComposer bComp = new org.pdfclown.documents.contents.composition.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, org.pdfclown.documents.contents.composition.YAlignmentEnum.Middle);
                bComp.ShowText(_Colunas[i].Cabecalho.ToUpper());
                bComp.End();

                composer.SafeDrawRectangle(r);
            }
        }
Exemple #9
0
        protected override void ToXObjectInternal(org.pdfclown.documents.contents.composition.PrimitiveComposer comp)
        {
            org.pdfclown.documents.contents.composition.BlockComposer bComp = new org.pdfclown.documents.contents.composition.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, org.pdfclown.documents.contents.composition.XAlignmentEnum.Center, org.pdfclown.documents.contents.composition.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));
        }
Exemple #10
0
        internal int PrintTable(org.pdfclown.documents.contents.composition.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);
        }