Exemple #1
0
        /// <summary>
        /// Renderiza o bloco para um XObject.
        /// </summary>
        public virtual org.pdfclown.documents.contents.xObjects.XObject ToXObject()
        {
            if (_RenderedObject == null)
            {
                _RenderedObject = new org.pdfclown.documents.contents.xObjects.FormXObject(Danfe.Document, Size);

                org.pdfclown.documents.contents.composition.PrimitiveComposer composer = new org.pdfclown.documents.contents.composition.PrimitiveComposer(_RenderedObject);
                var obj = composer.BeginLocalState();
                composer.SetLineWidth(DanfeDocumento.LineWidth);

                if (PossuiCabecalho)
                {
                    RectangleF rect = GetHeaderInnerRectangle();
                    //Danfe.PrintCabecalhoBloco2(composer, rect.Top, rect.Left, rect.Width, Cabecalho);
                    PrintCabecalho(composer);
                }

                ToXObjectInternal(composer);

                foreach (var campo in Campos)
                {
                    campo.Print(composer, Danfe.Font, Danfe.FontBold);
                }

                composer.Stroke();

                composer.End();
                composer.Flush();
            }

            return(_RenderedObject);
        }
Exemple #2
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 #3
0
        protected override void ToXObjectInternal(org.pdfclown.documents.contents.composition.PrimitiveComposer composer)
        {
            DanfeProdutosServicosTabela table = new DanfeProdutosServicosTabela(Danfe);
            table.Valores = CellValues;

            int end = table.PrintTable(composer, InternalRectangle, ProdutoIndex);

            if (ProdutoIndex == end)
            {
                throw new Exception("O índice do produto não foi incrementado ao gerar a tabela.");
            }

            ProdutoIndexEnd = end;
       
            composer.Stroke();
        }
Exemple #4
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 #5
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(org.pdfclown.documents.contents.composition.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 org.pdfclown.documents.contents.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();
        }
Exemple #6
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 #7
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);
        }