示例#1
0
 private void CreateInstance()
 {
     _model        = CreateInstanceEmpenho();
     _modelReforco = CreateInstanceEmpenhoRefoco();
     _mes          = CreateInsatanceEmpenhoMes(_model);
     _item         = CreateInsatanceEmpenhoItem(_model);
 }
 private IList <IMes> CreateInsatanceEmpenhoMes(Model.Entity.Empenho.Empenho objModel)
 {
     return(new List <IMes>
     {
         new EmpenhoMes {
             ValorMes = 2000M, Id = objModel.Id, Descricao = "12"
         }
     });
 }
 private List <EmpenhoItem> CreateInsatanceEmpenhoItem(Model.Entity.Empenho.Empenho objModel)
 {
     return(new List <EmpenhoItem>
     {
         new EmpenhoItem {
             ValorUnitario = 123, EmpenhoId = objModel.Id
         },
         new EmpenhoItem {
             ValorUnitario = 2852345, EmpenhoId = objModel.Id
         },
         new EmpenhoItem {
             ValorUnitario = 3425, EmpenhoId = objModel.Id
         },
         new EmpenhoItem {
             ValorUnitario = 412345, EmpenhoId = objModel.Id
         }
     });
 }
示例#4
0
        public void ConsultaNeTest()
        {
            var empenho = new Model.Entity.Empenho.Empenho
            {
                DataEmissao          = DateTime.Now,
                CodigoGestao         = "16055",
                CodigoUnidadeGestora = "162101",
                NumeroProcesso       = "processo1",
                CodigoUGO            = 162101,
                NumeroEmpenhoSiafem  = "2016NE00016",
                //NumeroEmpenhoSiafisico = "2016NE00012"
            };

            var result = App.SiafemEmpenhoService.ConsultaNe(AppConfig.WsSiafemUser /*AppConfig.WsSiafisicoUser*/, AppConfig.WsPassword, empenho, "162101");

            var teste = GerarPdfEmpenho(result, "Empenho", empenho);

            Assert.IsNotNull(teste);
        }
示例#5
0
        public static FileStreamResult GerarPdfEmpenho(ConsultaNe consulta, string tipo, Model.Entity.Empenho.Empenho empenho)
        {
            #region Configuraçao

            var meses = new List <mes>();

            var properties = consulta.GetType().GetProperties().ToList();

            int i = 0;
            foreach (var propertyInfo in properties)
            {
                if (propertyInfo.Name.Contains("Mes"))
                {
                    if (propertyInfo.GetValue(consulta).ToString() != "")
                    {
                        mes mes = new mes {
                            Mes = propertyInfo.GetValue(consulta).ToString(), Valor = ""
                        };
                        meses.Add(mes);
                    }

                    i += 1;
                }
            }

            i = 0;
            foreach (var propertyInfo in properties)
            {
                if (propertyInfo.Name.Contains("Valor") && propertyInfo.Name != "Valor")
                {
                    if (propertyInfo.GetValue(consulta).ToString() != "")
                    {
                        meses[i].Valor = propertyInfo.GetValue(consulta).ToString();
                        i += 1;
                    }
                }
            }


            var fileName = consulta.NumeroNe + ".pdf";

            string file = @"C:\Users\810235\Documents/" + fileName;

            FileInfo newFile = new FileInfo(file);

            if (newFile.Exists)
            {
                newFile.Delete();
            }

            int inicio     = 30;
            int linha      = 68;
            int pularLinha = 13;

            var document = new PdfDocument();
            var page     = document.AddPage();
            page.Size = PageSize.A4;
            var graphics      = XGraphics.FromPdfPage(page);
            var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);

            double val    = 0;
            double espaco = 25;

            var diretorio = GerarImagem();

            #endregion

            #region Cabeçario

            // Imagem.
            graphics.DrawImage(XImage.FromFile(diretorio), inicio - 20, 20, 60, 72);

            // Textos.
            //textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
            textFormatter.DrawString("GOVERNO DO ESTADO DE SÃO PAULO", new XFont("Calibri", 12, XFontStyle.Bold), XBrushes.Black, new XRect(85, linha, page.Width - 60, page.Height - 60));

            linha += 32;
            textFormatter.DrawString("Nota de " + tipo, new XFont("Calibri", 18.5, XFontStyle.Regular), XBrushes.Black, new XRect(inicio - 20, linha, page.Width - 60, page.Height - 60));

            // Figuras geométricas.
            linha += 20;
            graphics.DrawRectangle(XPens.Silver, XBrushes.White, new XRect(inicio - 20, linha, page.Width - 20, 0.1));


            #endregion

            #region Bloco1


            //Nº do Documento
            linha += 30;
            textFormatter.DrawString("Nº do Documento:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Nº do Documento:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.NumeroNe, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));

            //Data Emissão
            val += graphics.MeasureString("Nº do Documento:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
            textFormatter.DrawString("Data da Emissão:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));

            val += graphics.MeasureString("Data da Emissão:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.DataEmissao, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));

            //Nº do Documento Prodesp
            linha += (pularLinha);
            textFormatter.DrawString("Nº do Empenho Prodesp:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Nº do Empenho Prodesp:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(empenho.NumeroEmpenhoProdesp ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));



            //Gestão
            linha += pularLinha;
            textFormatter.DrawString("Gestão:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Gestão:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.Gestao, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));


            //Nº Processo
            linha += (pularLinha);
            textFormatter.DrawString("Nº Processo:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Nº Processo:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.NumeroProcesso, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));

            #endregion

            #region Bloco2
            //Credor
            linha += (pularLinha * 2);
            textFormatter.DrawString("Credor:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Credor:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.GestaoCredor, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));

            linha += (pularLinha);
            //CPF / CNPJ
            textFormatter.DrawString("CPF / CNPJ:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("CPF / CNPJ:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.CgcCpf, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));

            //Origem do Material
            linha += (pularLinha * 2);
            textFormatter.DrawString("Origem do Material:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Origem do Material:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.OrigemMaterial, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));

            #endregion

            #region Bloco3

            //Evento
            linha += (pularLinha * 2);
            textFormatter.DrawString("Evento", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Evento:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
            textFormatter.DrawString(consulta.Evento, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));

            val = 0;
            //UO
            linha += (pularLinha * 2);
            textFormatter.DrawString("UO", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(consulta.Uo, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));


            //PT
            val += graphics.MeasureString("UO", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
            textFormatter.DrawString("Programa de Trabalho", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(consulta.Pt, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));

            //Fonte
            val += graphics.MeasureString("Programa de Trabalho", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
            textFormatter.DrawString("Fonte", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(consulta.Fonte, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));


            //Natureza Despesa
            val += graphics.MeasureString("Fonte", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
            textFormatter.DrawString("Nat. Desp.", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(consulta.Despesa, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));

            //UGR
            val += graphics.MeasureString("Nat. Desp.", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
            textFormatter.DrawString("UGR", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(consulta.Ugo, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));

            //Plano Interno
            val += graphics.MeasureString("UGR", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
            textFormatter.DrawString("PI", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(consulta.PlanoInterno, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));


            #endregion

            #region Bloco3
            //ReferenciaLegal
            linha += (pularLinha * 3);
            textFormatter.DrawString("Refer. Legal:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Refer. Legal:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.ReferenciaLegal, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));

            //EmpenhoOriginal
            textFormatter.DrawString("Empenho Orig:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect((page.Width * 0.45), linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Empenho Orig:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.EmpenhoOriginal, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect((page.Width * 0.45) + val, linha, page.Width - 60, page.Height - 60));

            //Licitação
            linha += (pularLinha);
            textFormatter.DrawString("Licitação:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Licitação:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.Licitacao, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));


            //Modalidade
            textFormatter.DrawString("Modalidade:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect((page.Width * 0.45), linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Modalidade:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.Modalidade, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect((page.Width * 0.45) + val, linha, page.Width - 60, page.Height - 60));

            //Tipo Empenho
            linha += (pularLinha);
            textFormatter.DrawString("Tipo Empenho:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Tipo Empenho:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.TipoEmpenho, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));


            //Modalidade
            textFormatter.DrawString("Nº do Contrato:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect((page.Width * 0.45), linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Nº do Contrato:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.NumeroContrato, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect((page.Width * 0.45) + val, linha, page.Width - 60, page.Height - 60));

            #endregion

            #region Bloco4
            linha += (pularLinha);
            if (!string.IsNullOrEmpty(empenho.NumeroEmpenhoSiafem))
            {
                //Obra
                textFormatter.DrawString("Nº da Obra:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black,
                                         new XRect(inicio, linha, page.Width - 60, page.Height - 60));

                val = graphics.MeasureString("Nº da Obra:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
                textFormatter.DrawString(consulta.IdentificadorObra, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));



                //Unidade de Medida
                linha += (pularLinha * 2);
                textFormatter.DrawString("Unidade de Medida:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(consulta.Repete.tabela.unidade, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio, linha + pularLinha, page.Width - 60, page.Height - 60));

                //Valor Unitario
                val = graphics.MeasureString("Unidade de Medida:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
                textFormatter.DrawString("Valor Unitario:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(consulta.Repete.tabela.valorunitario, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));

                //Preço Total
                val += graphics.MeasureString("Valor Unitario:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
                textFormatter.DrawString("Preço Total:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(consulta.Repete.tabela.precototal, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));
            }

            #endregion

            #region Bloco5
            linha += (pularLinha);
            if (!string.IsNullOrEmpty(empenho.NumeroEmpenhoSiafisico))
            {
                val = 0;
                //Unidade de Medida
                linha += (pularLinha * 2);
                textFormatter.DrawString("Item Seq.", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(consulta.Repete.tabela.sequencia, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio, linha + pularLinha, page.Width - 60, page.Height - 60));

                //Item Serviço
                val += graphics.MeasureString("Item Seq.", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
                textFormatter.DrawString("Item Serviço", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(consulta.Repete.tabela.item, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));

                //Quantidade do Item
                val += graphics.MeasureString("Item Serviço", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
                textFormatter.DrawString("Quantidade do Item", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(consulta.Repete.tabela.qtdeitem, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));

                //Valor Unitario
                val += graphics.MeasureString("Quantidade do Item:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
                textFormatter.DrawString("Valor Unitario", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(consulta.Repete.tabela.valorunitario, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));


                //Preço Total
                val += graphics.MeasureString("Valor Unitario", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
                textFormatter.DrawString("Preço Total", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(consulta.Repete.tabela.precototal, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));
            }

            #endregion

            #region Bloco6

            linha += pularLinha * 3;

            //Valor Empenho
            textFormatter.DrawString("Valor Empenho:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Valor Empenho:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.Valor, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));


            #endregion


            #region Bloco7



            linha += (pularLinha * 3);
            textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
            textFormatter.DrawString("Cronograma de Desembolso Previsto", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Cronograma de Desembolso Previsto", new XFont("Calibri", 10, XFontStyle.Bold)).Width / 2;
            graphics.DrawRectangle(XPens.Silver, XBrushes.White, new XRect(inicio - 20, linha + 11.8, page.Width - 20, 0.1));



            linha += (pularLinha * 2);
            textFormatter.DrawString("Janeiro", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio - val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(meses.FirstOrDefault(x => x.Mes == "01")?.Valor ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio - val, linha + pularLinha, page.Width - 60, page.Height - 60));


            textFormatter.DrawString("Fevereiro", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(meses.FirstOrDefault(x => x.Mes == "02")?.Valor ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio, linha + pularLinha, page.Width - 60, page.Height - 60));


            textFormatter.DrawString("Março", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(meses.FirstOrDefault(x => x.Mes == "03")?.Valor ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));


            linha += (pularLinha * 2);
            textFormatter.DrawString("Abril", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio - val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(meses.FirstOrDefault(x => x.Mes == "04")?.Valor ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio - val, linha + pularLinha, page.Width - 60, page.Height - 60));


            textFormatter.DrawString("Maio", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(meses.FirstOrDefault(x => x.Mes == "05")?.Valor ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio, linha + pularLinha, page.Width - 60, page.Height - 60));


            textFormatter.DrawString("Junho", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(meses.FirstOrDefault(x => x.Mes == "06")?.Valor ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));


            linha += (pularLinha * 2);
            textFormatter.DrawString("Julho", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio - val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(meses.FirstOrDefault(x => x.Mes == "07")?.Valor ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio - val, linha + pularLinha, page.Width - 60, page.Height - 60));


            textFormatter.DrawString("Agosto", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(meses.FirstOrDefault(x => x.Mes == "08")?.Valor ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio, linha + pularLinha, page.Width - 60, page.Height - 60));


            textFormatter.DrawString("Setembro", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(meses.FirstOrDefault(x => x.Mes == "09")?.Valor ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));


            linha += (pularLinha * 2);
            textFormatter.DrawString("Outubro", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio - val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(meses.FirstOrDefault(x => x.Mes == "10")?.Valor ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio - val, linha + pularLinha, page.Width - 60, page.Height - 60));


            textFormatter.DrawString("Novembro", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(meses.FirstOrDefault(x => x.Mes == "11")?.Valor ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio, linha + pularLinha, page.Width - 60, page.Height - 60));


            textFormatter.DrawString("Dezembro", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(meses.FirstOrDefault(x => x.Mes == "12")?.Valor ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, linha + pularLinha, page.Width - 60, page.Height - 60));

            #endregion


            #region bloco8



            linha += (pularLinha * 9);
            textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
            textFormatter.DrawString("Lançado Por:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Lançado Por:", new XFont("Calibri", 10, XFontStyle.Bold)).Width;
            textFormatter.DrawString(consulta.Lancadopor, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val + 5, linha, page.Width - 60, page.Height - 60));


            textFormatter.DrawString("Em:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + (page.Width * 0.6), linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Em:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.DataLancamento, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + (page.Width * 0.6) + val, linha, page.Width - 60, page.Height - 60));


            textFormatter.DrawString("Às:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + (page.Width * 0.715), linha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Às:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(consulta.HoraLancamento, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + (page.Width * 0.715) + val, linha, page.Width - 60, page.Height - 60));


            var text = "Impresso através de consulta Web Service ao SIAFEM na data " + DateTime.Now.ToShortDateString() + " e hora " + consulta.HoraConsulta;

            textFormatter.DrawString(text, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio, page.Height - 40, page.Width - 60, page.Height - 60));

            textFormatter.DrawString("Nº FCO:", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio, page.Height - 40 + pularLinha, page.Width - 60, page.Height - 60));

            val = graphics.MeasureString("Nº FCO:", new XFont("Calibri", 10, XFontStyle.Bold)).Width + 2;
            textFormatter.DrawString(empenho.NumeroEmpenhoProdesp ?? "", new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + val, page.Height - 40 + pularLinha, page.Width - 60, page.Height - 60));


            #endregion

            document.Save(fileName);
            System.Diagnostics.Process.Start(fileName);

            var contentType = "application/pdf";

            MemoryStream stream = new MemoryStream {
                Position = 0
            };
            document.Save(stream, false);
            stream.Position = 0;

            var fileDownloadName = string.Format("{0}.pdf", consulta.NumeroNe);

            var fsr = new FileStreamResult(stream, contentType)
            {
                FileDownloadName = fileDownloadName
            };

            return(fsr);
        }