Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public org.pdfclown.documents.contents.objects.ContentObject ToInlineObject(org.pdfclown.documents.contents.composition.PrimitiveComposer composer)
        {
            var barcodeObject = composer.BeginLocalState();

            RectangleF  innerRect = new RectangleF(MargemHorizontal, MargemVertical, Size.Width - 2 * MargemHorizontal, Size.Height - 2 * MargemVertical);
            List <byte> codeBytes = new List <byte>();

            codeBytes.Add(105);

            for (int i = 0; i < this.Code.Length; i += 2)
            {
                byte b = byte.Parse(this.Code.Substring(i, 2));
                codeBytes.Add(b);
            }

            // Calcular dígito verificador
            int cd = 105;

            for (int i = 1; i < codeBytes.Count; i++)
            {
                cd += i * codeBytes[i];
                cd %= 103;
            }

            codeBytes.Add((byte)cd);
            codeBytes.Add(106);

            float n = codeBytes.Count * 11 + 2;
            float w = innerRect.Width / n;

            float x = 0;

            for (int i = 0; i < codeBytes.Count; i++)
            {
                byte[] pt = Barcode128C.Dic[codeBytes[i]];

                for (int i2 = 0; i2 < pt.Length; i2++)
                {
                    if (i2 % 2 == 0)
                    {
                        composer.SafeDrawRectangle(new RectangleF(innerRect.X + x, innerRect.Y, w * pt[i2], innerRect.Height));
                    }

                    x += w * pt[i2];
                }
            }

            composer.Fill();
            composer.End();
            return(barcodeObject);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
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();
        }