Esempio n. 1
0
        // GET: Documentos


        public FileResult GerarRelatorio()
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;
                var graphics = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page);
                var corFonte = PdfSharpCore.Drawing.XBrushes.Black;

                var textFormatter          = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                var fonteOrganzacao        = new PdfSharpCore.Drawing.XFont("Arial", 10);
                var fonteDescricao         = new PdfSharpCore.Drawing.XFont("Arial", 8, PdfSharpCore.Drawing.XFontStyle.BoldItalic);
                var titulodetalhes         = new PdfSharpCore.Drawing.XFont("Arial", 14, PdfSharpCore.Drawing.XFontStyle.Bold);
                var fonteDetalhesDescricao = new PdfSharpCore.Drawing.XFont("Arial", 7);

                var logo = @"C:\Users\Rafael\source\repos\Igreja.Com\Igreja.Com.Web\wwwroot\Imagens\logo.jpg";

                var qtdPaginas = doc.PageCount;
                textFormatter.DrawString(qtdPaginas.ToString(), new PdfSharpCore.Drawing.XFont("Arial", 10), corFonte, new PdfSharpCore.Drawing.XRect(578, 825, page.Width, page.Height));

                // Impressão do LogoTipo
                XImage imagem = XImage.FromFile(logo);
                graphics.DrawImage(imagem, 20, 10, 100, 50);

                textFormatter.DrawString("Igreja Evangelica Assembleia de Deus", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(225, 15, 150, 150));
                textFormatter.DrawString("Avenida Leopoldo de Matos", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(250, 35, 150, 150));
                textFormatter.DrawString("Guajará-Mirim RO", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(265, 55, 150, 150));

                var tituloDetalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                tituloDetalhes.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Center;
                tituloDetalhes.DrawString("Ficha Cadastro de Membro ", titulodetalhes, corFonte, new PdfSharpCore.Drawing.XRect(0, 90, page.Width, page.Height));

                textFormatter.DrawString("O senhor é meu pastor e nada me faltará", new PdfSharpCore.Drawing.XFont("Arial", 10), corFonte, new PdfSharpCore.Drawing.XRect(225, 825, page.Width, page.Height));

                int posicao = 130;
                var membro  = new MembroPDF();

                foreach (var propertyInfo in membro.GetType().GetProperties())
                {
                    textFormatter.DrawString(propertyInfo.Name, fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, posicao, page.Width, page.Height));
                    textFormatter.DrawString("___________________________________", fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(85, posicao, page.Width, page.Height));

                    posicao = posicao + 25;
                }


                using (MemoryStream stream = new MemoryStream())
                {
                    var contantType = "application/pdf";
                    doc.Save(stream, false);

                    var nomeArquivo = "RelatorioValdir.pdf";

                    return(File(stream.ToArray(), contantType, nomeArquivo));
                }
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Download(CompraUsuario compraUsuario, IWebHostEnvironment _environment)
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                #region Configuracoes da folha

                var page = doc.AddPage();

                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;

                var graphics = XGraphics.FromPdfPage(page);
                var corFonte = XBrushes.Black;

                #endregion

                #region Numeração das paginas

                int qtdPaginas = doc.PageCount;

                var numeracaoPagina = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                numeracaoPagina.DrawString(Convert.ToString(qtdPaginas), new PdfSharpCore.Drawing.XFont("Arial", 10), corFonte, new PdfSharpCore.Drawing.XRect(575, 825, page.Width, page.Height));

                #endregion

                #region Logo

                var    webRoot    = _environment.WebRootPath;
                var    logoFatura = string.Concat(webRoot, "/img/", "loja-virtual-1.png");
                XImage imagem     = XImage.FromFile(logoFatura);
                graphics.DrawImage(imagem, 20, 5, 300, 50);

                #endregion

                #region Informações 2

                var alturaTituloDetalhesY = 120;

                var detalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);

                var tituloInfo_1 = new PdfSharpCore.Drawing.XFont("Arial", 8, XFontStyle.Regular);

                detalhes.DrawString("Dados do banco", tituloInfo_1, corFonte, new XRect(25, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString("Banco Itau 004", tituloInfo_1, corFonte, new XRect(150, alturaTituloDetalhesY, page.Width, page.Height));

                alturaTituloDetalhesY += 9;
                detalhes.DrawString("Código Gerado", tituloInfo_1, corFonte, new XRect(25, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString("000000 000000 000000 000000", tituloInfo_1, corFonte, new XRect(150, alturaTituloDetalhesY, page.Width, page.Height));


                alturaTituloDetalhesY += 9;
                detalhes.DrawString("Quantidade:", tituloInfo_1, corFonte, new XRect(25, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString(compraUsuario.QuantidadeProdutos.ToString(), tituloInfo_1, corFonte, new XRect(150, alturaTituloDetalhesY, page.Width, page.Height));

                alturaTituloDetalhesY += 9;
                detalhes.DrawString("Valor Total:", tituloInfo_1, corFonte, new XRect(25, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString(compraUsuario.QuantidadeProdutos.ToString(), tituloInfo_1, corFonte, new XRect(150, alturaTituloDetalhesY, page.Width, page.Height));

                var tituloInfo_2 = new PdfSharpCore.Drawing.XFont("Arial", 8, XFontStyle.Bold);


                try
                {
                    var img = await GeraQrCode("Dados do banco aqui");

                    Stream streamImage = new MemoryStream(img);

                    XImage qrCode = XImage.FromStream(() => streamImage);

                    alturaTituloDetalhesY += 40;
                    graphics.DrawImage(qrCode, 140, alturaTituloDetalhesY, 310, 310);
                }
                catch (Exception erro)
                {
                }

                alturaTituloDetalhesY += 620;
                detalhes.DrawString("Canhoto com QrCode para pagamento online.", tituloInfo_2, corFonte, new XRect(20, alturaTituloDetalhesY, page.Width, page.Height));

                #endregion

                using (MemoryStream stream = new MemoryStream())
                {
                    var contentType = "application/pdf";

                    doc.Save(stream, false);
                    return(File(stream.ToArray(), contentType, "BoletoLojaOnline.pdf"));
                }
            }
        }
Esempio n. 3
0
        public FileResult GerarRelatorio()
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;
                var graphics               = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page);
                var corFonte               = PdfSharpCore.Drawing.XBrushes.Black;
                var textFormatter          = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                var fonteOrganizacao       = new PdfSharpCore.Drawing.XFont("Arial", 10);
                var fonteDescricao         = new PdfSharpCore.Drawing.XFont("Arial", 8, PdfSharpCore.Drawing.XFontStyle.BoldItalic);
                var titulodetalhes         = new PdfSharpCore.Drawing.XFont("Arial", 14, PdfSharpCore.Drawing.XFontStyle.Bold);
                var fonteDetalhesDescricao = new PdfSharpCore.Drawing.XFont("Arial", 7);

                var logo = @"C:\TestesDev\PdfSharp\PdfSharp\PdfSharp\wwwroot\imagens\transferir.jpg";

                var qtdPaginas = doc.PageCount;

                textFormatter.DrawString(qtdPaginas.ToString(), new PdfSharpCore.Drawing.XFont("Arial", 10), corFonte, new PdfSharpCore.Drawing.XRect(578, 825, page.Width, page.Height));


                //Impressão do logo
                XImage imagem = XImage.FromFile(logo);
                graphics.DrawImage(imagem, 20, 5, 300, 50);

                textFormatter.DrawString("Nome :", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 75, page.Width, page.Height));
                textFormatter.DrawString("Thiago Lanza", fonteOrganizacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 75, page.Width, page.Height));

                textFormatter.DrawString("Profissão :", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 95, page.Width, page.Height));
                textFormatter.DrawString("Programador", fonteOrganizacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 95, page.Width, page.Height));

                textFormatter.DrawString("Tempo :", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 115, page.Width, page.Height));
                textFormatter.DrawString("2 anos", fonteOrganizacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 115, page.Width, page.Height));

                // Título maior
                var tituloDetalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                tituloDetalhes.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Center;
                tituloDetalhes.DrawString("Detalhes", titulodetalhes, corFonte, new PdfSharpCore.Drawing.XRect(0, 120, page.Width, page.Height));


                //Título das colunas
                var alturaTituloDetalhesY = 140;
                var detalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);

                detalhes.DrawString("Descrição", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Atendimento", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(144, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Operação", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(220, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Quantidade", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(290, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Status", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(360, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Data", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(420, alturaTituloDetalhesY, page.Width, page.Height));

                //dados do relatório
                var alturaDetalhesItens = 160;

                void gerarTexto(string texto, int largura)
                {
                    textFormatter.DrawString(texto, fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(largura, alturaDetalhesItens, page.Width, page.Height));
                }

                for (int i = 1; i < 30; i++)
                {
                    string IToString        = i.ToString();
                    string TextoDescricao   = "Descrição :" + IToString;
                    string TextoAtendimento = "Atendimento : " + IToString;
                    string TextoOperacao    = "Operação : " + IToString;
                    string TextoQuantidade  = "Quantidade : " + IToString;
                    string TextoStatus      = "Status : " + IToString;

                    gerarTexto(TextoDescricao, 15);
                    gerarTexto(TextoAtendimento, 145);
                    gerarTexto(TextoOperacao, 215);
                    gerarTexto(TextoQuantidade, 290);
                    gerarTexto(TextoStatus, 360);
                    gerarTexto(DateTime.Now.ToString(), 420);
                    alturaDetalhesItens += 20;
                }


                using (MemoryStream stream = new MemoryStream())
                {
                    var contentType = "application/pdf";

                    doc.Save(stream, false);

                    var nomeArquivo = "relatorioThiago.pdf";

                    return(File(stream.ToArray(), contentType, nomeArquivo));
                }
            }
        }
        public async Task <FileResult> GerarRelatorio()
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;
                var graphics = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page);
                var corFonte = PdfSharpCore.Drawing.XBrushes.Black;

                var textFormatter          = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                var fonteOrganzacao        = new PdfSharpCore.Drawing.XFont("Arial", 10);
                var fonteDescricao         = new PdfSharpCore.Drawing.XFont("Arial", 8, PdfSharpCore.Drawing.XFontStyle.BoldItalic);
                var titulodetalhes         = new PdfSharpCore.Drawing.XFont("Arial", 14, PdfSharpCore.Drawing.XFontStyle.Bold);
                var fonteDetalhesDescricao = new PdfSharpCore.Drawing.XFont("Arial", 7);

                var logo = @"wwwroot\imagens\logo.jpg";



                var qtdPaginas = doc.PageCount;

                textFormatter.DrawString(qtdPaginas.ToString(), new PdfSharpCore.Drawing.XFont("Arial", 10), corFonte, new PdfSharpCore.Drawing.XRect(575, 825, page.Width, page.Height));

                // Impressão do LogoTipo
                XImage imagem = XImage.FromFile(logo);
                graphics.DrawImage(imagem, 50, 10, 500, 100);

                // Titulo Exibição
                textFormatter.DrawString(" Nome : ", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 130, page.Width, page.Height));
                textFormatter.DrawString(" Agência de Advocacia ", fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 130, page.Width, page.Height));

                textFormatter.DrawString(" Cliente : ", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 150, page.Width, page.Height));
                textFormatter.DrawString(" Unibrasil2020 ", fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 150, page.Width, page.Height));

                textFormatter.DrawString(" Processo : ", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 170, page.Width, page.Height));
                textFormatter.DrawString(DateTime.Now.ToString(), fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 170, page.Width, page.Height));


                // Titulo maior
                var tituloDetalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                tituloDetalhes.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Center;
                tituloDetalhes.DrawString(" Detalhes ", titulodetalhes, corFonte, new PdfSharpCore.Drawing.XRect(0, 200, page.Width, page.Height));


                // titulo das colunas
                var alturaTituloDetalhesY = 240;
                var detalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);

                detalhes.DrawString("Nome", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(67, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("CPF", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(200, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Telefone", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(325, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("E-mail", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(470, alturaTituloDetalhesY, page.Width, page.Height));



                //dados do relatório
                var alturaDetalhesItens = 260;
                var clientes            = await _context.Cliente.ToListAsync();

                foreach (var a in clientes)
                {
                    textFormatter.DrawString(a.Nome_Cliente, fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(60, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(a.CPF_Cliente, fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(190, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(a.Telefone_Cliente.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(325, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(a.Email_Cliente, fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(460, alturaDetalhesItens, page.Width, page.Height));
                    alturaDetalhesItens += 20;
                }


                using (MemoryStream stream = new MemoryStream())
                {
                    var contantType = "application/pdf";
                    doc.Save(stream, false);

                    var nomeArquivo = "RelatorioAdvocaciaPPFinal.pdf";

                    return(File(stream.ToArray(), contantType, nomeArquivo));
                }
            }
        }
        public async Task <FileResult> Download()
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;
                var graphics               = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page);
                var corFonte               = PdfSharpCore.Drawing.XBrushes.Black;
                var textFormatter          = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                var fonteOrganizacao       = new PdfSharpCore.Drawing.XFont("Ariel", 10);
                var fonteDescricao         = new PdfSharpCore.Drawing.XFont("Ariel", 8, PdfSharpCore.Drawing.XFontStyle.BoldItalic);
                var tituloDetalhes         = new PdfSharpCore.Drawing.XFont("Ariel", 8, PdfSharpCore.Drawing.XFontStyle.Bold);
                var fonteDetalhesDescricao = new PdfSharpCore.Drawing.XFont("Ariel", 7);
                var qtdPaginas             = doc.PageCount;

                //imagem logotipo
                var logo = @"C:\Users\dionn\Desktop\Ferman19.05.2020\PROJETO_FUP_Brasil\wwwroot\img\logo.jpg";
                textFormatter.DrawString(qtdPaginas.ToString(), new PdfSharpCore.Drawing.XFont("Arial", 10), corFonte, new PdfSharpCore.Drawing.XRect(575, 825, page.Width, page.Height));
                XImage imagem = XImage.FromFile(logo);
                graphics.DrawImage(imagem, 20, 5, 100, 50);


                //Titulo Maior
                var descricaoFinanceira = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                descricaoFinanceira.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Center;
                descricaoFinanceira.DrawString("Detalhamento Financeiro", tituloDetalhes, corFonte, new PdfSharpCore.Drawing.XRect(0, 120, page.Width, page.Height));

                //titulo das Colunas
                var alturaTituloFinanceiroY = 140;
                var detalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);

                detalhes.DrawString("Saida", fonteDescricao, PdfSharpCore.Drawing.XBrushes.Red, new PdfSharpCore.Drawing.XRect(20, alturaTituloFinanceiroY, page.Width, page.Height));
                detalhes.DrawString("Entrada", fonteDescricao, PdfSharpCore.Drawing.XBrushes.Green, new PdfSharpCore.Drawing.XRect(220, alturaTituloFinanceiroY, page.Width, page.Height));
                detalhes.DrawString("Total Liquido", fonteDescricao, PdfSharpCore.Drawing.XBrushes.DodgerBlue, new PdfSharpCore.Drawing.XRect(340, alturaTituloFinanceiroY, page.Width, page.Height));


                //gerar dados do relátorio

                FinanceiroViewModel model = new FinanceiroViewModel();
                var alturaItens           = 160;
                var alturaItens2          = 160;
                var conteudoAluno         = await _context.Aluno.Include(d => d.Cursos).ToListAsync();

                var conteudoFuncionario = await _context.Funcionario.ToListAsync();

                model.Funcionarios = conteudoFuncionario;
                model.Alunos       = conteudoAluno;
                decimal somaDespesas = 0;
                decimal somaLucros   = 0;
                decimal totalLiquido = 0;


                foreach (var item in model.Funcionarios)
                {
                    textFormatter.DrawString("Saida: " + item.SalarioFuncionario, fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, alturaItens, page.Width, page.Height));
                    somaDespesas += item.SalarioFuncionario;
                    alturaItens  += 20;
                }


                foreach (var item in model.Alunos)
                {
                    textFormatter.DrawString("Entrada: " + item.Cursos.ValorCurso, fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(220, alturaItens2, page.Width, page.Height));
                    somaLucros   += item.Cursos.ValorCurso;
                    alturaItens2 += 20;
                }
                totalLiquido = somaLucros - somaDespesas;
                textFormatter.DrawString("Total Saida: " + somaDespesas, fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, alturaItens, page.Width, page.Height));
                textFormatter.DrawString("Total Entrada: " + somaLucros, fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(220, alturaItens2, page.Width, page.Height));
                textFormatter.DrawString("Total Liquido: " + totalLiquido, fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(340, alturaItens2, page.Width, page.Height));



                //cabeçalho inicio statico
                textFormatter.DrawString("Instituição: ", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 95, page.Width, page.Height));
                textFormatter.DrawString("Faculdade Universitaria de Programação", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(80, 95, page.Width, page.Height));
                //cabeçalho das colunas



                using (MemoryStream stream = new MemoryStream())
                {
                    var contantType = "application/pdf";
                    doc.Save(stream, false);
                    var nomeArquivo = "relatorioFinancerio.pdf";
                    return(File(stream.ToArray(), contantType, nomeArquivo));
                }
            }
        }
Esempio n. 6
0
        public async Task <FileResult> DownloadAluno()
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;
                var graphics               = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page);
                var corFonte               = PdfSharpCore.Drawing.XBrushes.Black;
                var textFormatter          = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                var fonteOrganizacao       = new PdfSharpCore.Drawing.XFont("Ariel", 10);
                var fonteDescricao         = new PdfSharpCore.Drawing.XFont("Ariel", 8, PdfSharpCore.Drawing.XFontStyle.BoldItalic);
                var tituloDetalhes         = new PdfSharpCore.Drawing.XFont("Ariel", 8, PdfSharpCore.Drawing.XFontStyle.Bold);
                var fonteDetalhesDescricao = new PdfSharpCore.Drawing.XFont("Ariel", 7);
                var logo       = @"D:\3Periodo\Ferman26.05 ultima versao\PROJETO_FUP_Brasil\wwwroot\img\logo.jpg";
                var qtdPaginas = doc.PageCount;

                //imagem logotipo
                textFormatter.DrawString(qtdPaginas.ToString(), new PdfSharpCore.Drawing.XFont("Arial", 10), corFonte, new PdfSharpCore.Drawing.XRect(575, 825, page.Width, page.Height));
                XImage imagem = XImage.FromFile(logo);
                graphics.DrawImage(imagem, 20, 5, 100, 50);


                //Titulo Maior
                var descricaoFinanceira = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                descricaoFinanceira.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Center;
                descricaoFinanceira.DrawString("Alunos do Curso", tituloDetalhes, corFonte, new PdfSharpCore.Drawing.XRect(0, 120, page.Width, page.Height));

                //titulo das Colunas
                var alturaTituloFinanceiroY = 140;
                var detalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);

                detalhes.DrawString("Aluno", fonteDescricao, PdfSharpCore.Drawing.XBrushes.Red, new PdfSharpCore.Drawing.XRect(20, alturaTituloFinanceiroY, page.Width, page.Height));
                detalhes.DrawString("Curso", fonteDescricao, PdfSharpCore.Drawing.XBrushes.Green, new PdfSharpCore.Drawing.XRect(220, alturaTituloFinanceiroY, page.Width, page.Height));

                //gerar dados do relátorio

                Cursos model         = new Cursos();
                var    alturaItens   = 160;
                var    alturaItens2  = 160;
                var    conteudoAluno = await _context.Aluno.Include(d => d.Cursos).ToListAsync();

                model.Aluno = conteudoAluno;

                if (model.Aluno != null)
                {
                    foreach (var item in model.Aluno)
                    {
                        textFormatter.DrawString("Aluno: " + item.Nome, fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, alturaItens, page.Width, page.Height));
                        alturaItens += 20;
                    }


                    foreach (var item in model.Aluno)
                    {
                        textFormatter.DrawString("Curso: " + item.Cursos.NomeCurso, fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(220, alturaItens2, page.Width, page.Height));
                        alturaItens2 += 20;
                    }
                }

                //cabeçalho inicio statico
                textFormatter.DrawString("Instituição: ", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 95, page.Width, page.Height));
                textFormatter.DrawString("Faculdade Universitaria de Programação", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(80, 95, page.Width, page.Height));



                using (MemoryStream stream = new MemoryStream())
                {
                    var contantType = "application/pdf";
                    doc.Save(stream, false);
                    var nomeArquivo = "relatorioFinancerio.pdf";
                    return(File(stream.ToArray(), contantType, nomeArquivo));
                }
            }
        }
        public FileResult GerarRelatorio()
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;
                var graphic  = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page);
                var corFonte = PdfSharpCore.Drawing.XBrushes.Black;

                var textFormatter          = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphic);
                var fonteOrganizacao       = new PdfSharpCore.Drawing.XFont("Arial", 10);
                var fonteDescricao         = new PdfSharpCore.Drawing.XFont("Arial", 8, PdfSharpCore.Drawing.XFontStyle.BoldItalic);
                var tituloDetalhes         = new PdfSharpCore.Drawing.XFont("Arial", 14, PdfSharpCore.Drawing.XFontStyle.Bold);
                var fonteDetalhesDescricao = new PdfSharpCore.Drawing.XFont("Arial", 7);

                var logo = @"C:\Users\Alexander\source\repos\PDFSharpAspNetCore\PDFSharpAspNetCore\wwwroot\images\transferir.jpg";

                var qtdPaginas = doc.PageCount;
                textFormatter.DrawString(qtdPaginas.ToString(), new PdfSharpCore.Drawing.XFont("Arial", 10), corFonte, new PdfSharpCore.Drawing.XRect(578, 825, page.Width, page.Height));

                //Impressão do Logo
                var imagem = XImage.FromFile(logo);
                graphic.DrawImage(imagem, 20, 5, 300, 50);

                // Titulo Exibição
                textFormatter.DrawString("Nome: ", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 75, page.Width, page.Height));
                textFormatter.DrawString("Alexander Silva ", fonteOrganizacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 75, page.Width, page.Height));

                textFormatter.DrawString("Profissão :", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 95, page.Width, page.Height));
                textFormatter.DrawString("Desenvolvedor de Software", fonteOrganizacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 95, page.Width, page.Height));

                textFormatter.DrawString("Tempo :", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 115, page.Width, page.Height));
                textFormatter.DrawString("01 ano", fonteOrganizacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 115, page.Width, page.Height));

                // Titulo Maior
                var tituloDetalhesMaior = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphic);
                tituloDetalhesMaior.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Center;
                tituloDetalhesMaior.DrawString("RELATÓRIO ", tituloDetalhes, corFonte, new PdfSharpCore.Drawing.XRect(0, 120, page.Width, page.Height));

                // Titulo Colunas
                var alturaTituloDetalhesY = 140;
                var detalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphic);

                detalhes.DrawString("Descrição ", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString("Atendimento", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(144, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString("Operação", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(220, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString("Quantidade", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(290, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString("Status", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(337, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString("Data", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(400, alturaTituloDetalhesY, page.Width, page.Height));

                // Dados Relatório
                var alturaDetalhesItens = 160;
                for (int i = 1; i < 30; i++)
                {
                    textFormatter.DrawString("Descrição" + ": " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(21, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString("Atendimento" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(145, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString("Operação" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(215, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString("Quantidade" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(290, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString("Status" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(332, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(DateTime.Now.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(400, alturaDetalhesItens, page.Width, page.Height));

                    alturaDetalhesItens += 20;
                }

                using (var stream = new MemoryStream())
                {
                    var contentType = "application/pdf";
                    doc.Save(stream, false);
                    var nomeArquivo = "Relatorio.pdf";
                    return(File(stream.ToArray(), contentType, nomeArquivo));
                }
            }
        }
        //DateTime searchDtIni, DateTime searchDtFim
        public FileResult GerarRelatorio(String searchDtIni, String searchDtFim)
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;
                var graphics = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page);
                var corFonte = PdfSharpCore.Drawing.XBrushes.Black;

                var textFormatter          = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                var fonteOrganzacao        = new PdfSharpCore.Drawing.XFont("Arial", 10);
                var fonteDescricao         = new PdfSharpCore.Drawing.XFont("Arial", 8, PdfSharpCore.Drawing.XFontStyle.BoldItalic);
                var titulodetalhes         = new PdfSharpCore.Drawing.XFont("Arial", 14, PdfSharpCore.Drawing.XFontStyle.Bold);
                var fonteDetalhesDescricao = new PdfSharpCore.Drawing.XFont("Arial", 7);

                var logo = @"Imgs\logo_questorQ.png";

                var qtdPaginas = doc.PageCount;
                textFormatter.DrawString(qtdPaginas.ToString(), new PdfSharpCore.Drawing.XFont("Arial", 10), corFonte, new PdfSharpCore.Drawing.XRect(578, 825, page.Width, page.Height));

                // Impressão do LogoTipo
                XImage imagem = XImage.FromFile(logo);
                graphics.DrawImage(imagem, 20, 5, 300, 50);

                // Titulo Exibição
                textFormatter.DrawString("Nome :", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 75, page.Width, page.Height));
                textFormatter.DrawString("João", fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 75, page.Width, page.Height));

                textFormatter.DrawString("Loja :", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 95, page.Width, page.Height));
                textFormatter.DrawString("Garagem do João", fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 95, page.Width, page.Height));

                // Titulo maior
                var tituloDetalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                tituloDetalhes.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Center;
                tituloDetalhes.DrawString("Anuncios ", titulodetalhes, corFonte, new PdfSharpCore.Drawing.XRect(0, 120, page.Width, page.Height));

                // titulo das colunas
                var alturaTituloDetalhesY = 140;
                var detalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);

                detalhes.DrawString("Marca", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString("Modelo", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(80, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString("Ano Veiculo", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(120, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString("Valor de Venda", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(180, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString("Lucro", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(250, alturaTituloDetalhesY, page.Width, page.Height));
                detalhes.DrawString("Data Venda", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(350, alturaTituloDetalhesY, page.Width, page.Height));

                //dados do relatório
                var alturaDetalhesItens = 160;

                DateTime dateIni = DateTime.ParseExact(searchDtIni, "dd/MM/yyyy", null);
                DateTime dateFim = DateTime.ParseExact(searchDtFim, "dd/MM/yyyy", null);

                var anuncioss = from AN in _context.Anuncio
                                join MA in _context.Marca on AN.IdMarca equals MA.ID
                                where AN.DataVenda >= dateIni && AN.DataVenda <= dateFim
                                select AN;

                var webGaragemContext = anuncioss.Include(a => a.Marca).Include(a => a.Modelo);

                foreach (var item in webGaragemContext)
                {
                    textFormatter.DrawString(item.Marca.NomeMarca, fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(21, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.Modelo.NomeModelo, fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(80, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.AnoVeiculo, fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(120, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.ValorVenda.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(180, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString((item.ValorVenda - item.ValorCompra).ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(250, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.DataVenda.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(350, alturaDetalhesItens, page.Width, page.Height));

                    alturaDetalhesItens += 20;
                }

                using (MemoryStream stream = new MemoryStream())
                {
                    var contantType = "application/pdf";
                    doc.Save(stream, false);

                    var nomeArquivo = "RelatorioJoao.pdf";

                    return(File(stream.ToArray(), contantType, nomeArquivo));
                }
            }
        }
Esempio n. 9
0
        public FileResult GerarRelatorio()
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument()) {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;

                List <Malote> lst = new List <Malote>();
                lst.Add(new Malote()
                {
                    Remetente = "Teste", Cidade = "Teste"
                });

                var grafics          = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page);
                var corFonte         = PdfSharpCore.Drawing.XBrushes.Black;
                var textFormatter    = new PdfSharpCore.Drawing.Layout.XTextFormatter(grafics);
                var fonteOrganizacao = new PdfSharpCore.Drawing.XFont("Arial", 10);
                var fonteTitulo      = new PdfSharpCore.Drawing.XFont("Arial", 10, PdfSharpCore.Drawing.XFontStyle.Bold);
                var fonteDesc        = new PdfSharpCore.Drawing.XFont("Arial", 8, PdfSharpCore.Drawing.XFontStyle.Bold);
                var titulo           = new PdfSharpCore.Drawing.XFont("Arial", 14, PdfSharpCore.Drawing.XFontStyle.Bold);
                var fonteDetalhes    = new PdfSharpCore.Drawing.XFont("Arial", 7);
                var logo             = @"C:\Logo.png";

                var qtdpaginas = doc.PageCount;

                textFormatter.DrawString(qtdpaginas.ToString(), new PdfSharpCore.Drawing.XFont("Arial", 7), corFonte,
                                         new PdfSharpCore.Drawing.XRect(575, 825, page.Width, page.Height));

                XImage imagem = XImage.FromFile(logo);
                grafics.DrawImage(imagem, 160, 15, 280, 150);

                textFormatter.DrawString("Protocolo de Envio de Malote", titulo, corFonte, new PdfSharpCore.Drawing.XRect(200, 160, page.Width, page.Height));

                textFormatter.DrawString("REMETENTE", fonteTitulo, corFonte, new PdfSharpCore.Drawing.XRect(70, 210, page.Width, page.Height));
                textFormatter.DrawString("DESTINO", fonteTitulo, corFonte, new PdfSharpCore.Drawing.XRect(170, 210, page.Width, page.Height));
                textFormatter.DrawString("N. LACRE ", fonteTitulo, corFonte, new PdfSharpCore.Drawing.XRect(270, 210, page.Width, page.Height));
                textFormatter.DrawString("PERCURSO", fonteTitulo, corFonte, new PdfSharpCore.Drawing.XRect(370, 210, page.Width, page.Height));
                textFormatter.DrawString("N. MALOTE", fonteTitulo, corFonte, new PdfSharpCore.Drawing.XRect(470, 210, page.Width, page.Height));


                List <Malote> alunos = new List <Malote>();

                MySqlConnection con = new MySqlConnection();
                con.ConnectionString = c.ConexaoDados();
                con.Open();
                string data = DateTime.Now.ToShortDateString();
                //Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand("SELECT" + '"' + "Remetente" + '"' + " , " + '"' + "Cidade" + "FROM" + '"' + "MaloteModel" + '"', con);
                MySqlCommand    command = new MySqlCommand("SELECT * FROM Malote  WHERE  DataEnvio = '" + DateTime.Today.ToString("yyyy/MM/dd") + "'", con);
                MySqlDataReader reader  = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        alunos.Add(new Malote()
                        {
                            CidadeSaida = reader.GetString("CidadeSaida"),
                            Cidade      = reader.GetString("Cidade"),
                            Lacre       = reader.GetInt32("Lacre"),
                            Percurso    = reader.GetInt32("Percurso"),
                            Numero      = reader.GetInt32("Numero")
                        });
                    }
                    Console.WriteLine(data);
                }

                var alturaItens = 230;
                for (int i = 0; i < alunos.Count; i++)
                {
                    textFormatter.DrawString(alunos[i].CidadeSaida, fonteOrganizacao, corFonte, new PdfSharpCore.Drawing.XRect(70, alturaItens, page.Width, page.Height));
                    textFormatter.DrawString(alunos[i].Cidade, fonteOrganizacao, corFonte, new PdfSharpCore.Drawing.XRect(170, alturaItens, page.Width, page.Height));
                    textFormatter.DrawString(alunos[i].Lacre.ToString(), fonteOrganizacao, corFonte, new PdfSharpCore.Drawing.XRect(270, alturaItens, page.Width, page.Height));
                    textFormatter.DrawString(alunos[i].Percurso.ToString(), fonteOrganizacao, corFonte, new PdfSharpCore.Drawing.XRect(370, alturaItens, page.Width, page.Height));
                    textFormatter.DrawString(alunos[i].Numero.ToString(), fonteOrganizacao, corFonte, new PdfSharpCore.Drawing.XRect(470, alturaItens, page.Width, page.Height));

                    alturaItens += 20;
                }

                textFormatter.DrawString("________________________________", fonteOrganizacao, corFonte,
                                         new PdfSharpCore.Drawing.XRect(50, 750, page.Width, page.Height));

                textFormatter.DrawString("________________________________", fonteOrganizacao, corFonte,
                                         new PdfSharpCore.Drawing.XRect(360, 750, page.Width, page.Height));

                textFormatter.DrawString("Correios", fonteOrganizacao, corFonte,
                                         new PdfSharpCore.Drawing.XRect(50, 770, page.Width, page.Height));

                textFormatter.DrawString("Grupo Bellinati", fonteOrganizacao, corFonte,
                                         new PdfSharpCore.Drawing.XRect(360, 770, page.Width, page.Height));


                using (MemoryStream stream = new MemoryStream()) {
                    var contentType = "application/pdf";
                    doc.Save(stream, false);
                    var nomeArquivo = "Protocolo do Malote: " + DateTime.Today.ToString("dd/MM/yyyy") + ".pdf";

                    return(File(stream.ToArray(), contentType, nomeArquivo));
                }
            }
        }
        //Método Criado para o PDF
        public FileResult GerarRelatorio()
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;
                var graphics = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page);
                var corFonte = PdfSharpCore.Drawing.XBrushes.Black;

                var textFormatter          = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                var fonteOrganzacao        = new PdfSharpCore.Drawing.XFont("Arial", 10);
                var fonteDescricao         = new PdfSharpCore.Drawing.XFont("Arial", 8, PdfSharpCore.Drawing.XFontStyle.BoldItalic);
                var titulodetalhes         = new PdfSharpCore.Drawing.XFont("Arial", 14, PdfSharpCore.Drawing.XFontStyle.Bold);
                var fonteDetalhesDescricao = new PdfSharpCore.Drawing.XFont("Arial", 7);
                var webRoot    = _environment.WebRootPath;
                var logo       = string.Concat(webRoot, "/imagens/logo.jpg");
                var qtdPaginas = doc.PageCount;
                textFormatter.DrawString(qtdPaginas.ToString(), new PdfSharpCore.Drawing.XFont("Arial", 10), corFonte, new PdfSharpCore.Drawing.XRect(578, 825, page.Width, page.Height));

                // Impressão do LogoTipo
                XImage imagem = XImage.FromFile(logo);
                graphics.DrawImage(imagem, 20, 5, 300, 50);


                // Titulo Exibição
                textFormatter.DrawString("Nome :", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 75, page.Width, page.Height));
                textFormatter.DrawString("Valdir Ferreira ", fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 75, page.Width, page.Height));

                textFormatter.DrawString("Profissão :", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 95, page.Width, page.Height));
                textFormatter.DrawString("Programador", fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 95, page.Width, page.Height));

                textFormatter.DrawString("Tempo :", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 115, page.Width, page.Height));
                textFormatter.DrawString("10 anos", fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 115, page.Width, page.Height));


                // Titulo maior
                var tituloDetalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                tituloDetalhes.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Center;
                tituloDetalhes.DrawString("Detalhes ", titulodetalhes, corFonte, new PdfSharpCore.Drawing.XRect(0, 120, page.Width, page.Height));


                // titulo das colunas
                var alturaTituloDetalhesY = 140;
                var detalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);

                detalhes.DrawString("Descrição", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Atendimento", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(144, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Operação", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(220, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Quantidade", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(290, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Status", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(337, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Data", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(400, alturaTituloDetalhesY, page.Width, page.Height));


                //dados do relatório
                var alturaDetalhesItens = 160;
                for (int i = 1; i < 30; i++)
                {
                    textFormatter.DrawString("Descrição" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(21, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString("Atendimento" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(145, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString("Operação" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(215, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString("Quantidade" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(290, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString("Status" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(332, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(DateTime.Now.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(400, alturaDetalhesItens, page.Width, page.Height));

                    alturaDetalhesItens += 20;
                }



                #region //ADICIONAR NOVA PAGINA

                page             = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;
                graphics         = XGraphics.FromPdfPage(page);
                corFonte         = XBrushes.Black;

                fonteOrganzacao        = new PdfSharpCore.Drawing.XFont("Arial", 10);
                fonteDescricao         = new PdfSharpCore.Drawing.XFont("Arial", 8, PdfSharpCore.Drawing.XFontStyle.BoldItalic);
                titulodetalhes         = new PdfSharpCore.Drawing.XFont("Arial", 14, PdfSharpCore.Drawing.XFontStyle.Bold);
                fonteDetalhesDescricao = new PdfSharpCore.Drawing.XFont("Arial", 7);
                detalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);



                logo       = string.Concat(webRoot, "/imagens/logo.jpg");
                qtdPaginas = doc.PageCount;
                detalhes.DrawString(qtdPaginas.ToString(), new PdfSharpCore.Drawing.XFont("Arial", 10), corFonte, new PdfSharpCore.Drawing.XRect(578, 825, page.Width, page.Height));

                // Impressão do LogoTipo
                imagem = XImage.FromFile(logo);
                graphics.DrawImage(imagem, 20, 5, 300, 50);

                var alturaDetalhesItensPageNew = 160;
                for (int i = 1; i < 30; i++)
                {
                    detalhes.DrawString("Descrição" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(21, alturaDetalhesItensPageNew, page.Width, page.Height));
                    detalhes.DrawString("Atendimento" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(145, alturaDetalhesItensPageNew, page.Width, page.Height));
                    detalhes.DrawString("Operação" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(215, alturaDetalhesItensPageNew, page.Width, page.Height));
                    detalhes.DrawString("Quantidade" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(290, alturaDetalhesItensPageNew, page.Width, page.Height));
                    detalhes.DrawString("Status" + " : " + i.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(332, alturaDetalhesItensPageNew, page.Width, page.Height));
                    detalhes.DrawString(DateTime.Now.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(400, alturaDetalhesItensPageNew, page.Width, page.Height));

                    alturaDetalhesItensPageNew += 20;
                }
                #endregion


                using (MemoryStream stream = new MemoryStream())
                {
                    var contantType = "application/pdf";
                    doc.Save(stream, false);

                    var nomeArquivo = "RelPDF.pdf";

                    //return File(stream.ToArray(), contantType, nomeArquivo);

                    FileContentResult result = new FileContentResult(stream.ToArray(), "application/pdf");


                    return(result);
                }
            }

            //return View();
        }