public PdfDocumentInfo BuildDocument(string directoryPath, PdfClientPdfDocument document)
        {
            EnsureArg.IsNotNullOrEmpty(directoryPath, nameof(directoryPath));
            EnsureArg.IsNotNull(document, nameof(document));

            using var pdfDocument = new PdfDocument();

            foreach (var documentPage in document.Pages)
            {
                var page = pdfDocument.AddPage();
                page.Size = PdfSharpCore.PageSize.A4;

                using var gfx       = XGraphics.FromPdfPage(page);
                using XImage xImage = XImage.FromStream(() => documentPage.DataStream);

                gfx.DrawImage(xImage, 0, 0, page.Width.Point, page.Height.Point);
            }

            pdfDocument.Save($"{directoryPath}/{document.Title}.pdf");

            return(new PdfDocumentInfo
            {
                Created = DateTime.UtcNow,
                FilePath = $"{directoryPath}/{document.Title}.pdf",
            });
        }
Esempio n. 2
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. 3
0
        static void TestPdfReader()
        {
            string fn = @"C:\Program Files\Microsoft\R Client\R_SERVER\doc\manual\fullrefman.pdf";

            int version = PdfSharpCore.Pdf.IO.PdfReader.TestPdfFile(fn);

            System.Console.WriteLine(version);

            using (PdfSharpCore.Pdf.PdfDocument pr = PdfSharpCore.Pdf.IO.PdfReader.Open(fn))
            {
                System.Console.WriteLine(pr.Pages.Count);
            }
        }
Esempio n. 4
0
        public static void CropPdf()
        {
            double baseY = 0;

            PdfSharpCore.Pdf.PdfDocument outputDocument =
                new PdfSharpCore.Pdf.PdfDocument();

            PdfSharpCore.Pdf.PdfPage page = outputDocument.AddPage();

            //page.Height = PdfSharpCore.Drawing.XUnit.FromMillimeter(baseY + 10).Point;
            double height = PdfSharpCore.Drawing.XUnit.FromMillimeter(baseY + 10).Point;

            page.CropBox = new PdfSharpCore.Pdf.PdfRectangle(
                new PdfSharpCore.Drawing.XPoint(0, page.Height - height),
                new PdfSharpCore.Drawing.XSize(page.Width, height));
        }
Esempio n. 5
0
        public FileResult ExportToPDF(Guid id)
        {
            const string facename = "Cambria";

            PdfDocument document = new PdfDocument();

            PdfSharpCore.Pdf.PdfPage page = document.AddPage();

            document.Info.Title    = "Student Information";
            document.Info.Author   = "Ankitkumar Singh";
            document.Info.Subject  = "Student Card";
            document.Info.Keywords = "student-card";

            XGraphics gfx  = XGraphics.FromPdfPage(page);
            XFont     font = new XFont(facename, 20, XFontStyle.BoldItalic);

            Student studentDetails = _studentRepository.GetStudent(id);

            XFont fontRegular = new XFont(facename, 14, XFontStyle.Regular);
            XFont fontBold    = new XFont(facename, 14, XFontStyle.Bold);

            gfx.DrawString("Student Card", font, XBrushes.Black, new XRect(0, 40, page.Width, page.Height), XStringFormats.TopCenter);
            gfx.DrawString("Student Id : " + studentDetails.Id, fontRegular, XBrushes.Black, 200, 140);
            gfx.DrawString("Name : " + studentDetails.FirstName + " " + studentDetails.LastName, fontBold, XBrushes.Black, 200, 165);
            gfx.DrawString("Contact : " + studentDetails.Contact, fontBold, XBrushes.Black, 200, 190);
            gfx.DrawString("Subject Id : " + studentDetails.PhdSubjectId, fontBold, XBrushes.Black, 200, 215);
            gfx.DrawString("Subject Name : " + studentDetails.phdSubject.Name, fontBold, XBrushes.Black, 200, 240);

            XImage image = XImage.FromFile("D:\\Ankitkumar-Singh\\Asp-Core-Mvc\\test finally done\\Asp-Core-Test\\Asp-Core-Test\\wwwroot\\images\\qrcode.png");

            gfx.DrawImage(image, 20, 120, 150, 150);

            const string filename = "UserIdentityCard.pdf";

            document.Save(filename);
            string ReportURL = "UserIdentityCard.pdf";

            byte[] FileBytes = System.IO.File.ReadAllBytes(ReportURL);
            return(File(FileBytes, "application/pdf"));
        }
        //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();
        }
Esempio n. 7
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> 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. 9
0
 private void CreatePDF()
 {
     pdf = document.GetDocument();
 }
Esempio n. 10
0
        static void Main(string[] args)
        {
            // TfsRemover.RemoveTFS();
            TreeInfo ti = GetAncestors();

            int maxNumPeople = (int)System.Math.Pow(2.0, (double)ti.MaxGeneration);

            System.Console.WriteLine(maxNumPeople);

            System.Collections.Generic.Dictionary <int, System.Collections.Generic.Dictionary <int
                                                                                               , DataPoint> > dict
                = new System.Collections.Generic.Dictionary <int
                                                             , System.Collections.Generic.Dictionary <int, DataPoint> >();

            PdfSharpCore.Fonts.GlobalFontSettings.FontResolver = new FontResolver();

            MigraDocCore.DocumentObjectModel.MigraDoc.DocumentObjectModel.Shapes
            .ImageSource.ImageSourceImpl = new PdfSharpCore.ImageSharp.ImageSharpImageSource <Rgba32>();


            using (PdfSharpCore.Pdf.PdfDocument document = new PdfSharpCore.Pdf.PdfDocument())
            {
                document.Info.Title    = "Family Tree";
                document.Info.Author   = "FamilyTree Ltd. - Stefan Steiger";
                document.Info.Subject  = "Family Tree";
                document.Info.Keywords = "Family Tree, Genealogical Tree, Genealogy, Bloodline, Pedigree";



                document.ViewerPreferences.Direction = PdfSharpCore.Pdf.PdfReadingDirection.LeftToRight;

                PdfSharpCore.Pdf.PdfPage page = document.AddPage();

                // page.Width = PdfSettings.PaperFormatSettings.Width
                // page.Height = PdfSettings.PaperFormatSettings.Height

                const double GOLDEN_RATIO = 1.61803398875;

                // https://en.wikipedia.org/wiki/Golden_ratio
                double marginLeft    = 125;
                double marginTop     = marginLeft;
                double textBoxWidth  = 200;
                double textBoxHeight = textBoxWidth / GOLDEN_RATIO;

                double textBoxVdistance      = textBoxHeight / (GOLDEN_RATIO / (GOLDEN_RATIO * GOLDEN_RATIO));
                double textBoxLargeHdistance = textBoxWidth / (GOLDEN_RATIO * GOLDEN_RATIO);
                double textBoxSmallHdistance = textBoxLargeHdistance / (GOLDEN_RATIO * GOLDEN_RATIO);



                int numGenerationsToList = 5;
                int maxGenerationIndex   = numGenerationsToList - 1;
                int numItems             = (int)System.Math.Pow(2, maxGenerationIndex);


                page.Orientation = PdfSharpCore.PageOrientation.Landscape;

                page.Width = marginLeft * 2
                             + numItems * textBoxWidth
                             + (numItems / 2) * textBoxSmallHdistance
                             + (numItems / 2 - 1) * textBoxLargeHdistance
                ;

                page.Height = marginTop * 2
                              + numGenerationsToList * textBoxHeight
                              + (numGenerationsToList - 1) * textBoxVdistance
                ;



                double dblLineWidth = 1.0;
                string strHtmlColor = "#FF00FF";
                PdfSharpCore.Drawing.XColor lineColor = XColorHelper.FromHtml(strHtmlColor);
                PdfSharpCore.Drawing.XPen   pen       = new PdfSharpCore.Drawing.XPen(lineColor, dblLineWidth);

                PdfSharpCore.Drawing.XFont font = new PdfSharpCore.Drawing.XFont("Arial"
                                                                                 , 12.0, PdfSharpCore.Drawing.XFontStyle.Bold
                                                                                 );


                using (PdfSharpCore.Drawing.XGraphics gfx = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page))
                {
                    gfx.MUH = PdfSharpCore.Pdf.PdfFontEncoding.Unicode;

                    PdfSharpCore.Drawing.Layout.XTextFormatter tf = new PdfSharpCore.Drawing.Layout.XTextFormatter(gfx);
                    tf.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Left;

                    PdfSharpCore.Drawing.Layout.XTextFormatterEx2 etf = new PdfSharpCore.Drawing.Layout.XTextFormatterEx2(gfx);


                    for (int generationNumber = maxGenerationIndex; generationNumber > -1; --generationNumber)
                    {
                        dict[generationNumber] = new System.Collections.Generic.Dictionary <int, DataPoint>();

                        int num = (int)System.Math.Pow(2.0, generationNumber);

                        for (int i = 0; i < num; ++i)
                        {
                            if (generationNumber != maxGenerationIndex)
                            {
                                var dp1 = dict[generationNumber + 1][i * 2];
                                var dp2 = dict[generationNumber + 1][i * 2 + 1];

                                var rect1 = dp1.rect;
                                var rect2 = dp2.rect;


                                double xNew = (rect1.TopLeft.X + rect2.TopRight.X) / 2.0;
                                double yNew = marginTop
                                              + generationNumber * textBoxHeight
                                              + generationNumber * textBoxVdistance;

                                gfx.DrawLine(pen, xNew, yNew + rect1.Height, rect1.X + rect1.Width / 2.0, rect1.Y);
                                gfx.DrawLine(pen, xNew, yNew + rect1.Height, rect2.X + rect2.Width / 2.0, rect2.Y);

                                xNew = xNew - rect1.Width / 2.0;

                                dict[generationNumber][i] = new DataPoint()
                                {
                                    Person = (
                                        from itemList in ti.ls[generationNumber]
                                        where itemList.Id == dp1.Person.Child
                                        select itemList
                                        ).FirstOrDefault(),
                                    rect = new DataStructures.Rectangle(xNew, yNew, rect1.Width, rect1.Height)
                                };
                            }
                            else
                            {
                                System.Console.WriteLine($"i: {i}");
                                int numSmallSpaces = (i + 1) / 2;
                                System.Console.WriteLine($"numSmallSpaces: {numSmallSpaces}");
                                int numPairs = i / 2;
                                System.Console.WriteLine($"numPairs: {numPairs}");


                                double rectX = marginLeft
                                               + i * textBoxWidth
                                               + numSmallSpaces * textBoxSmallHdistance
                                               + numPairs * textBoxLargeHdistance
                                ;

                                double rectY = marginTop
                                               + generationNumber * textBoxHeight
                                               + generationNumber * textBoxVdistance
                                ;


                                dict[generationNumber][i] = new DataPoint()
                                {
                                    Person = ti.ls[generationNumber][i],
                                    rect   = new DataStructures.Rectangle(rectX, rectY, textBoxWidth, textBoxHeight)
                                };
                            }

                            gfx.DrawRectangle(pen, dict[generationNumber][i].rect.ToXRect());


                            string text = $@"Generation {generationNumber} Person {i}";
                            text = dict[generationNumber][i].Person.composite_name;


                            tf.DrawString(text
                                          , font
                                          , PdfSharpCore.Drawing.XBrushes.Black
                                          , dict[generationNumber][i].rect.ToXRect()
                                          , PdfSharpCore.Drawing.XStringFormats.TopLeft
                                          );
                        } // Next i
                    }     // Next generationNumber
                }         // End Using gfx


                byte[] baPdfDocument;

                using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
                {
                    document.Save(ms, false);
                    ms.Flush();

                    // baPdfDocument = new byte[ms.Length];
                    // ms.Seek(0, System.IO.SeekOrigin.Begin);
                    // ms.Read(baPdfDocument, 0, (int)ms.Length);

                    baPdfDocument = ms.ToArray();
                } // End Using ms


                System.IO.File.WriteAllBytes("FamilyTree.pdf", baPdfDocument);
                //document.Save(filename);
            } // End Using document

            System.Console.WriteLine(System.Environment.NewLine);
            System.Console.WriteLine(" --- Press any key to continue --- ");
            System.Console.ReadKey();
        } // End Sub Main
 public GerarPdfCaixa()
 {
     _document = new PdfSharpCore.Pdf.PdfDocument();
 }
Esempio n. 12
0
        public FileResult GerarPdf()
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;

                var graphics              = XGraphics.FromPdfPage(page);
                var corFonte              = XBrushes.Black;
                var textFormatter         = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                var fonteOrganizacao      = new XFont("Arial", 10);
                var fonteDescricao        = new XFont("Arial", 12, XFontStyle.BoldItalic);
                var titulodetalhes        = new XFont("Arial", 14, XFontStyle.Bold);
                var fonteDetalheDescricao = new XFont("Arial", 7);

                //var logo = @"C:\Users\pedri\Desktop\CineManager\CineManager\CineManager\CineManager\wwwroot\logo-cm-ps.png";

                var qtdPaginas = doc.PageCount;

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

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

                textFormatter.DrawString("Filmes que ja estiveram disponiveis e estarão futuramente", fonteDescricao, corFonte,
                                         new XRect(20, 75, page.Width, page.Height));

                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));


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

                //titulo
                detalhes.DrawString("Filme", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, alturaTituloDetalhesY, page.Width, page.Height));

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


                //lançamento
                detalhes.DrawString("Lançamento", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(290, alturaTituloDetalhesY, page.Width, page.Height));

                //em cartaz
                detalhes.DrawString("Em cartaz até", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(430, alturaTituloDetalhesY, page.Width, page.Height));

                List <Filme> listaFilmes = _context.Filme.Include(x => x.Generos).Include(x => x.TiposFilme).ToList();


                var alturarDatalhesItens = 160;

                foreach (Filme f in listaFilmes)
                {
                    textFormatter.DrawString(f.Titulo.ToString(), fonteDetalheDescricao, corFonte,
                                             new XRect(15, alturarDatalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(f.Duracao.ToString(), fonteDetalheDescricao, corFonte,
                                             new XRect(220, alturarDatalhesItens, page.Width, page.Height));

                    textFormatter.DrawString(f.Lancamento.ToString().Substring(0, 10), fonteDetalheDescricao, corFonte,
                                             new XRect(290, alturarDatalhesItens, page.Width, page.Height));

                    textFormatter.DrawString(f.EmCartazAte.ToString().Substring(0, 10), fonteDetalheDescricao, corFonte,
                                             new XRect(430, alturarDatalhesItens, page.Width, page.Height));

                    alturarDatalhesItens += 20;
                }

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

                    doc.Save(stream, false);

                    var nomeArquivo = "relatorioFilmes.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));
                }
            }
        }
        public FileResult GerarRelatorio(int?id)
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument()) {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;

                var grafics          = XGraphics.FromPdfPage(page);
                var corFonte         = XBrushes.Black;
                var textFormatter    = new XTextFormatter(grafics);
                var textJustify      = new XTextFormatter(grafics);
                var fonteOrganizacao = new XFont("Times New Roman", 12);
                var fonteTitulo      = new XFont("Times New Roman", 12, XFontStyle.Bold);
                var fonteDesc        = new XFont("Times New Roman", 8, XFontStyle.Bold);
                var titulo           = new XFont("Times New Roman", 10, XFontStyle.Bold);
                var fonteDetalhes    = new XFont("Times New Roman", 7);
                var fonteNegrito     = new XFont("Times New Roman", 12, XFontStyle.Bold);
                var logo             = @"C:\Logo.png";
                var qtdpaginas       = doc.PageCount;


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

                List <JuntadaTermoCessao> dados = new List <JuntadaTermoCessao>();

                MySqlConnection con = new MySqlConnection();
                con.ConnectionString = c.ConexaoDados();
                con.Open();
                string          data    = DateTime.Now.ToShortDateString();
                MySqlCommand    command = new MySqlCommand("SELECT * FROM juntadatermocessao  WHERE  Id = '" + id + "'", con);
                MySqlDataReader reader  = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        dados.Add(new JuntadaTermoCessao()
                        {
                            Autos        = reader.GetString("Autos"),
                            Contrato     = reader.GetInt64("Contrato"),
                            Vara         = reader.GetString("Vara"),
                            Comarca      = reader.GetString("Comarca"),
                            Estado       = reader.GetString("Estado"),
                            Banco        = reader.GetString("Banco"),
                            Reu          = reader.GetString("Reu"),
                            BancoCedente = reader.GetString("BancoCedente"),
                            Oab          = reader.GetString("Oab"),
                            Data         = reader.GetString("Data")
                        });;
                    }
                    Console.WriteLine(data);
                }

                for (int i = 0; i < dados.Count; i++)
                {
                    //Imagem todo da pagina
                    XImage imagem = XImage.FromFile(logo);
                    grafics.DrawImage(imagem, 200, 40, 200, 80);

                    var topo =
                        "EXCELENTÍSSIMO SENHOR DOUTOR JUIZ DE DIREITO DA " + dados[i].Vara + " DA " + dados[i].Comarca + " – ESTADO DO " + dados[i].Estado;

                    var dadosAutos =
                        "Autos nº: " + dados[i].Autos + "\n" +
                        "Contrato nº: " + dados[i].Contrato;


                    var texto =
                        "                                 " + dados[i].Banco + ", já qualificado, conforme procuração anexa, vem, nos " +
                        "autos em epígrafe, que " + dados[i].BancoCedente + " litiga contra " + dados[i].Reu + ", já também devidamente " +
                        "qualificada, vem, por seu procurador signatário, respeitosamente, à Douta presença de Vossa Excelência, " +
                        "em atendimento ao despacho retro, REQUERER a juntada do comprovante da cessão do crédito, decorrente do " +
                        "contrato objeto da lide.\n \n \n" +

                        "                                 Diante deste fato, pugna a parte autora a admissão no polo ativo destes autos, " +
                        "como cessionária o " + dados[i].Banco + ", nos termos do artigo 567 II, " +
                        "do Código de Processo Civil, bem como sejam procedidas todas as anotações de estilo o cartório distribuidor e " +
                        "na autuação do feito, nos termos de termo de cessão específico acostado ao final.\n \n \n" +

                        "                                 Caso não seja o entendimento deste D. Juízo, requer de forma subsidiaria, " +
                        "que " + dados[i].Banco + ", figure como assistente litisconsorcial, com base no artigo 109, § 2ª, do CPC.\n \n \n" +

                        "                                 In fine, requer que todas as intimações se deem na forma prevista nos " +
                        "artigos 272 e 273 do NCPC, para que sejam publicadas apenas em nome da Dra. " +
                        "CRISTIANE BELLINATI GARCIA LOPES, " + dados[i].Oab + ", sob pena de nulidade da intimação, conforme previsto no " +
                        "artigo 280 do CPC.\n \n \n" +

                        "                                 Termos em que,\n" +
                        "                                 Pede deferimento.\n" +
                        "                                 Maringá / PR, " + dados[i].Data;


                    var oab =
                        "CRISTIANE BELINATI GARCIA LOPES\n" +
                        dados[i].Oab;

                    var enderecoRodape =
                        "Endereço: Rua João Paulino Vieira Filho, 625, 12º andar – Sala 1201\n" +
                        "Bairro: Zona 01 CEP: 87020-015 - Fone: (44) 3033-9291 / (44) 2103-9291\n" +
                        "Maringa/PR";

                    //Texto do Topo
                    textJustify.Alignment = XParagraphAlignment.Left;
                    XRect rectTopo = new XRect(48, 155, 490, page.Height);
                    textJustify.DrawString(topo, fonteTitulo, corFonte, rectTopo, XStringFormats.TopLeft);

                    //Dados do Contrato
                    textJustify.Alignment = XParagraphAlignment.Left;
                    XRect rectDados = new XRect(48, 230, 490, page.Height);
                    textJustify.DrawString(dadosAutos, fonteNegrito, corFonte, rectDados, XStringFormats.TopLeft);

                    //Dados do Texto
                    textJustify.Alignment = XParagraphAlignment.Justify;
                    XRect rectTexto = new XRect(48, 290, 490, page.Height);
                    textJustify.DrawString(texto, fonteOrganizacao, corFonte, rectTexto, XStringFormats.TopLeft);

                    //Texto OAB
                    textJustify.Alignment = XParagraphAlignment.Center;
                    XRect rectOab = new XRect(48, 680, 490, page.Height);
                    textJustify.DrawString(oab, fonteTitulo, corFonte, rectOab, XStringFormats.TopLeft);

                    textJustify.Alignment = XParagraphAlignment.Center;
                    XRect rectenderecoRodape = new XRect(48, 790, 490, page.Height);
                    textJustify.DrawString(enderecoRodape, fonteDetalhes, corFonte, rectenderecoRodape, XStringFormats.TopLeft);
                }

                using (MemoryStream stream = new MemoryStream()) {
                    var contentType = "application/pdf";
                    doc.Save(stream, false);
                    var nomeArquivo = "Juntada Termo de Cessão.pdf";
                    return(File(stream.ToArray(), contentType, nomeArquivo));
                }
            }
        }
Esempio n. 15
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));
                }
            }
        }
Esempio n. 16
0
        public FileResult DownloadAsync(int id)
        {
            var compra = _context.Compras.Find(id);

            /*if (compra == null)
             * {
             *  return NotFound();
             * }*/

            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", 10, PdfSharpCore.Drawing.XFontStyle.BoldItalic);
                var titulodetalhes         = new PdfSharpCore.Drawing.XFont("Arial", 12, PdfSharpCore.Drawing.XFontStyle.Bold);
                var fonteDetalhesDescricao = new PdfSharpCore.Drawing.XFont("Arial", 8);

                var tituloPrincipal = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                tituloPrincipal.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Center;
                tituloPrincipal.DrawString("Relatório Compra de Gado | Id Compra: " + compra.IdCompra, titulodetalhes, corFonte, new PdfSharpCore.Drawing.XRect(0, 40, page.Width, page.Height));


                // Titulo Exibição

                textFormatter.DrawString("Pecuarista: ", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 75, page.Width, page.Height));
                textFormatter.DrawString(compra.Comprador, fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(80, 75, page.Width, page.Height));

                textFormatter.DrawString("Id Pecuarista: ", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 95, page.Width, page.Height));
                textFormatter.DrawString(compra.CompradorId.ToString(), fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(90, 95, page.Width, page.Height));

                textFormatter.DrawString("Data de entrega: ", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 115, page.Width, page.Height));
                textFormatter.DrawString(compra.DataEntrega.ToString(), fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(100, 115, page.Width, page.Height));

                textFormatter.DrawString("Data da compra: ", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(20, 135, page.Width, page.Height));
                textFormatter.DrawString(compra.DataCompra.ToString(), fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(100, 135, page.Width, page.Height));


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


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

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

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

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

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


                //dados do relatório
                var alturaDetalhesItens = 190;
                var itens = _context.CompraGadoItems
                            .Include(x => x.Animal)
                            .Where(y => y.CompraGadoId == compra.IdCompra)
                            .ToList();
                var sum = 0.0;
                foreach (var item in itens)
                {
                    textFormatter.DrawString(item.Animal.Descricao.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(21, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.Quantidade.ToString(), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(145, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString("R$ " + double.Parse(item.Animal.Preco).ToString("C2"), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(215, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString((int.Parse(item.Quantidade) * double.Parse(item.Animal.Preco)).ToString("C2"), fonteDetalhesDescricao, corFonte, new PdfSharpCore.Drawing.XRect(290, alturaDetalhesItens, page.Width, page.Height));

                    sum += int.Parse(item.Quantidade) * double.Parse(item.Animal.Preco);
                    alturaDetalhesItens += 20;
                }

                textFormatter.DrawString("Total: R$", fonteDescricao, corFonte, new PdfSharpCore.Drawing.XRect(145, alturaDetalhesItens, page.Width, page.Height));
                textFormatter.DrawString(sum.ToString("C2"), fonteOrganzacao, corFonte, new PdfSharpCore.Drawing.XRect(190, alturaDetalhesItens, page.Width, page.Height));
                using (MemoryStream stream = new MemoryStream())
                {
                    var contantType = "application/pdf";
                    doc.Save(stream, false);

                    var nomeArquivo = "Relatorio_idpecuarista_" + compra.CompradorId
                                      + "_" + compra.Comprador + "CompraId" + compra.IdCompra + ".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));
                }
            }
        }
Esempio n. 18
0
        public FileResult RelatorioParcela(DateTime DataInicial, DateTime DataFinal)
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                //Query Parcelas Pagas
                var ParcelasPagas = _context.Parcelas.Include(f => f.Fatura.Cliente).Where(f => f.Fatura.DataEmissao.Date >= DataInicial.Date &&
                                                                                           f.Fatura.DataEmissao.Date <= DataFinal.Date &&
                                                                                           f.Status.Equals("Pago")).AsNoTracking().OrderBy(f => f.Vencimento).ToList();
                //Query Parcelas Vencidas
                var ParcelasVencidas = _context.Parcelas.Include(f => f.Fatura.Cliente).Where(f => f.Fatura.DataEmissao.Date >= DataInicial.Date &&
                                                                                              f.Fatura.DataEmissao.Date <= DataFinal.Date &&
                                                                                              f.Status.Equals("Vencido")).AsNoTracking().OrderBy(f => f.Vencimento).ToList();
                //Query Parcelas Pendente
                var ParcelasPendente = _context.Parcelas.Include(f => f.Fatura.Cliente).Where(f => f.Fatura.DataEmissao.Date >= DataInicial.Date &&
                                                                                              f.Fatura.DataEmissao.Date <= DataFinal.Date &&
                                                                                              f.Status.Equals("Pendente")).AsNoTracking().OrderBy(f => f.Vencimento).ToList();

                GerarPdfParcela gerarPdf = new GerarPdfParcela();
                int             Altura   = 200;
                int             Linhas   = 0;

                gerarPdf.AddPagina();
                gerarPdf.EscreverHead(DataInicial, DataFinal);
                gerarPdf.EscreverParcelaPagasTags();
                gerarPdf.EscreverNumeroPagina();

                foreach (var item in ParcelasPagas)
                {
                    gerarPdf.EscreverParcelaPagasCorpo(item, Altura);
                    Linhas++;
                    Altura += 20;

                    if (Linhas > 22)
                    {
                        gerarPdf.AddPagina();
                        Linhas = 0;
                        Altura = 200;
                        gerarPdf.EscreverHead(DataInicial, DataFinal);
                        gerarPdf.EscreverParcelaPagasTags();
                        gerarPdf.EscreverNumeroPagina();
                    }
                }

                gerarPdf.EscreverParcelaPendenteTags(Altura);

                foreach (var item in ParcelasPendente)
                {
                    gerarPdf.EscreverParcelaPendenteCorpo(item, Altura);
                    Linhas++;
                    Altura += 20;

                    if (Linhas > 22)
                    {
                        gerarPdf.AddPagina();
                        Linhas = 0;
                        Altura = 200;
                        gerarPdf.EscreverHead(DataInicial, DataFinal);
                        gerarPdf.EscreverParcelaPendenteTags(Altura);
                        gerarPdf.EscreverNumeroPagina();
                    }
                }

                gerarPdf.EscreverParcelaVencidaTags(Altura);

                foreach (var item in ParcelasVencidas)
                {
                    gerarPdf.EscreverParcelaVencidaCorpo(item, Altura);
                    Linhas++;
                    Altura += 20;

                    if (Linhas > 22)
                    {
                        gerarPdf.AddPagina();
                        Linhas = 0;
                        Altura = 200;
                        gerarPdf.EscreverHead(DataInicial, DataFinal);
                        gerarPdf.EscreverParcelaVencidaTags(Altura);
                        gerarPdf.EscreverNumeroPagina();
                    }
                }


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

                    gerarPdf._document.Save(stream, false);

                    var nomeArquivo = "Relatorio_Parcelas" + DataInicial.Date.ToString("d") + "_" + DataFinal.Date.ToString("d") + ".pdf";

                    return(File(stream.ToArray(), contantType, nomeArquivo));
                }
            }
        }
Esempio n. 19
0
        public FileResult RelatorioCaixa(DateTime DataInicial, DateTime DataFinal)
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                //Query Faturas
                var Faturamento = _context.Faturas.Include(f => f.Cliente).Where(f => f.DataEmissao.Date >= DataInicial.Date &&
                                                                                 f.DataEmissao.Date <= DataFinal.Date).AsNoTracking()
                                  .OrderBy(f => f.DataEmissao).ToList();
                //Query Despesas
                var Despesa = _context.Despesa.Include(d => d.TipoCusto).Where(f => f.Data.Date >= DataInicial.Date &&
                                                                               f.Data.Date <= DataFinal.Date).AsNoTracking()
                              .OrderBy(f => f.Data).ToList();
                //Query Saldo
                double Saldo = _context.Faturas.Where(f => f.DataEmissao.Date >= DataInicial.Date &&
                                                      f.DataEmissao.Date <= DataFinal.Date)
                               .Select(f => f.ValorFatura).Sum()
                               - _context.Despesa.Where(f => f.Data.Date >= DataInicial.Date &&
                                                        f.Data.Date <= DataFinal.Date)
                               .Select(f => f.Valor).Sum();

                GerarPdfCaixa gerarPdf = new GerarPdfCaixa();
                int           Altura   = 200;
                int           Linhas   = 0;

                gerarPdf.AddPagina();
                gerarPdf.EscreverHead(DataInicial, DataFinal);
                gerarPdf.EscreverFaturamentoTags();
                gerarPdf.EscreverNumeroPagina();

                foreach (var item in Faturamento)
                {
                    gerarPdf.EscreverFaturamentoCorpo(item, Altura);
                    Linhas++;
                    Altura += 20;

                    if (Linhas > 22)
                    {
                        gerarPdf.AddPagina();
                        Linhas = 0;
                        Altura = 200;
                        gerarPdf.EscreverHead(DataInicial, DataFinal);
                        gerarPdf.EscreverFaturamentoTags();
                        gerarPdf.EscreverNumeroPagina();
                    }
                }

                gerarPdf.EscreverDespesaTags(Altura);
                foreach (var item in Despesa)
                {
                    gerarPdf.EscreverDespesaCorpo(item, Altura);
                    Linhas++;
                    Altura += 20;

                    if (Linhas > 22)
                    {
                        gerarPdf.AddPagina();
                        Linhas = 0;
                        Altura = 150;
                        gerarPdf.EscreverHead(DataInicial, DataFinal);
                        gerarPdf.EscreverDespesaTags(Altura);
                        gerarPdf.EscreverNumeroPagina();
                    }
                }

                gerarPdf.EscreverSaldo(Saldo, Altura);

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

                    gerarPdf._document.Save(stream, false);

                    var nomeArquivo = "Relatorio_Parcelas" + DataInicial.Date.ToString("d") + "_" + DataFinal.Date.ToString("d") + ".pdf";

                    return(File(stream.ToArray(), contantType, nomeArquivo));
                }
            }
        }
Esempio n. 20
0
        public static void ReadPdf()
        {
            // Get a fresh copy of the sample PDF file
            string filename = "FamilyTree.pdf";

            // Create the output document
            PdfSharpCore.Pdf.PdfDocument outputDocument =
                new PdfSharpCore.Pdf.PdfDocument();

            // Show single pages
            // (Note: one page contains two pages from the source document)
            outputDocument.PageLayout = PdfSharpCore.Pdf.PdfPageLayout.SinglePage;

            /*
             * PdfSharpCore.Drawing.XFont font =
             *  new PdfSharpCore.Drawing.XFont("Verdana", 8, PdfSharpCore.Drawing.XFontStyle.Bold);
             * PdfSharpCore.Drawing.XStringFormat format = new PdfSharpCore.Drawing.XStringFormat();
             * format.Alignment = PdfSharpCore.Drawing.XStringAlignment.Center;
             * format.LineAlignment = PdfSharpCore.Drawing.XLineAlignment.Far;
             */
            PdfSharpCore.Drawing.XGraphics gfx;
            PdfSharpCore.Drawing.XRect     box;

            // Open the external document as XPdfForm object
            PdfSharpCore.Drawing.XPdfForm form =
                PdfSharpCore.Drawing.XPdfForm.FromFile(filename);

            for (int idx = 0; idx < form.PageCount; idx += 2)
            {
                // Add a new page to the output document
                PdfSharpCore.Pdf.PdfPage page = outputDocument.AddPage();
                page.Orientation = PdfSharpCore.PageOrientation.Landscape;
                double width  = page.Width;
                double height = page.Height;

                int rotate = page.Elements.GetInteger("/Rotate");

                gfx = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page);

                // Set page number (which is one-based)
                form.PageNumber = idx + 1;

                box = new PdfSharpCore.Drawing.XRect(0, 0, width / 2, height);
                // Draw the page identified by the page number like an image
                gfx.DrawImage(form, box);

                // Write document file name and page number on each page
                box.Inflate(0, -10);

                /*
                 * gfx.DrawString(string.Format("- {1} -", filename, idx + 1),
                 *   font, PdfSharpCore.Drawing.XBrushes.Red, box, format);
                 */
                if (idx + 1 < form.PageCount)
                {
                    // Set page number (which is one-based)
                    form.PageNumber = idx + 2;

                    box = new PdfSharpCore.Drawing.XRect(width / 2, 0, width / 2, height);
                    // Draw the page identified by the page number like an image
                    gfx.DrawImage(form, box);

                    // Write document file name and page number on each page
                    box.Inflate(0, -10);

                    /*
                     * gfx.DrawString(string.Format("- {1} -", filename, idx + 2),
                     *  font, PdfSharpCore.Drawing.XBrushes.Red, box, format);
                     */
                }
            }

            // Save the document...
            filename = "TwoPagesOnOne_tempfile.pdf";
            outputDocument.Save(filename);
            // ...and start a viewer.
            System.Diagnostics.Process.Start(filename);
        }
Esempio n. 21
0
        public IActionResult ImprimirHistorico(RequisicaoModel entity)
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;
                var graphics = XGraphics.FromPdfPage(page);
                var corFonte = XBrushes.Black;

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

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


                var cabecalho = entity.CarregarRegistro(entity.Id);

                var fonteTitulo = new XFont("Arial", 20, XFontStyle.Bold);

                // CABEÇALHO
                textFormatter.DrawString("HISTÓRICO DE REQUISIÇÃO", fonteTitulo, corFonte, new XRect(20, 30, page.Width, page.Height));
                // horizontal, vertical
                textFormatter.DrawString("Código requisição: ", fonteDescricao, corFonte, new XRect(20, 70, page.Width, page.Height));
                textFormatter.DrawString(cabecalho.Id.ToString(), fonteOrganzacao, corFonte, new XRect(95, 69, page.Width, page.Height));

                textFormatter.DrawString("Usuário requisitante: ", fonteDescricao, corFonte, new XRect(20, 90, page.Width, page.Height));
                textFormatter.DrawString(cabecalho.NomeUsuarioResponsavel, fonteOrganzacao, corFonte, new XRect(105, 89, page.Width, page.Height));

                textFormatter.DrawString("Data de abertura: ", fonteDescricao, corFonte, new XRect(20, 110, page.Width, page.Height));
                textFormatter.DrawString(cabecalho.Data.ToString(), fonteOrganzacao, corFonte, new XRect(95, 109, page.Width, page.Height));

                // DETALHE
                var tituloDetalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                tituloDetalhes.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Center;

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

                detalhes.DrawString("Data de alteração", fonteDescricao, corFonte, new XRect(20, alturaTituloDetalhesY, page.Width, page.Height));

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

                detalhes.DrawString("Usuário", fonteDescricao, corFonte, new XRect(500, alturaTituloDetalhesY, page.Width, page.Height));

                var dados = entity.ObterHistorico(entity.Id);

                //DADOS
                var alturaDetalhesItens = 160;
                foreach (var item in dados)
                {
                    textFormatter.DrawString(item.DataAlteracao.ToString(), fonteDetalhesDescricao, corFonte, new XRect(21, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.Descricao, fonteDetalhesDescricao, corFonte, new XRect(201, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.NomeUsuario, fonteDetalhesDescricao, corFonte, new XRect(501, alturaDetalhesItens, page.Width, page.Height));

                    alturaDetalhesItens += 20;
                }

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

                    var nomeArquivo = "Historico.pdf";

                    return(File(stream.ToArray(), contantType, nomeArquivo));
                }
            }
        }
Esempio n. 22
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));
                }
            }
        }
Esempio n. 23
0
        public IActionResult ImprimirMovimentacoes(RequisicaoModel entity)
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument())
            {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.Crown;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;
                var graphics = XGraphics.FromPdfPage(page);
                var corFonte = XBrushes.Black;

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

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


                var fonteTitulo = new XFont("Arial", 20, XFontStyle.Bold);

                // CABEÇALHO
                textFormatter.DrawString("MOVIMENTAÇÕES DE REQUISIÇÕES", fonteTitulo, corFonte, new XRect(20, 30, page.Width, page.Height));

                textFormatter.DrawString("Status: ", fonteDescricao, corFonte, new XRect(20, 70, page.Width, page.Height));
                textFormatter.DrawString(entity.Status, fonteOrganzacao, corFonte, new XRect(85, 69, page.Width, page.Height));

                textFormatter.DrawString("Período: ", fonteDescricao, corFonte, new XRect(20, 90, page.Width, page.Height));
                textFormatter.DrawString(entity.Data + " até " + entity.DataFinal, fonteOrganzacao, corFonte, new XRect(105, 89, page.Width, page.Height));

                // DETALHE
                var tituloDetalhes = new PdfSharpCore.Drawing.Layout.XTextFormatter(graphics);
                tituloDetalhes.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Center;

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

                detalhes.DrawString("Número", fonteDescricao, corFonte, new XRect(20, alturaTituloDetalhesY, page.Width, page.Height));

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

                detalhes.DrawString("Tipo", fonteDescricao, corFonte, new XRect(630, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Origem", fonteDescricao, corFonte, new XRect(710, alturaTituloDetalhesY, page.Width, page.Height));

                detalhes.DrawString("Destino", fonteDescricao, corFonte, new XRect(850, alturaTituloDetalhesY, page.Width, page.Height));

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

                detalhes.DrawString("Usuário", fonteDescricao, corFonte, new XRect(1200, alturaTituloDetalhesY, page.Width, page.Height));

                var dados = entity.ListaRequisicao();

                // DADOS
                var alturaDetalhesItens = 160;
                foreach (var item in dados)
                {
                    textFormatter.DrawString(item.Id.ToString(), fonteDetalhesDescricao, corFonte, new XRect(21, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.Descricao, fonteDetalhesDescricao, corFonte, new XRect(101, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.Tipo == "T" ? "Transbordo" : "Backload", fonteDetalhesDescricao, corFonte, new XRect(631, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.NomeEstacaoOrigem, fonteDetalhesDescricao, corFonte, new XRect(710, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.NomeEstacaoDestino, fonteDetalhesDescricao, corFonte, new XRect(850, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.Status, fonteDetalhesDescricao, corFonte, new XRect(1021, alturaDetalhesItens, page.Width, page.Height));
                    textFormatter.DrawString(item.NomeUsuarioAtual, fonteDetalhesDescricao, corFonte, new XRect(1200, alturaDetalhesItens, page.Width, page.Height));

                    alturaDetalhesItens += 20;
                }

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

                    var nomeArquivo = "Movimentacoes.pdf";

                    return(File(stream.ToArray(), contantType, nomeArquivo));
                }
            }
        }
Esempio n. 24
0
        static void OldSimpleMain(string[] args)
        {
            PdfSharpCore.Fonts.GlobalFontSettings.FontResolver = new FontResolver();

            MigraDocCore.DocumentObjectModel.MigraDoc.DocumentObjectModel.Shapes
            .ImageSource.ImageSourceImpl = new PdfSharpCore.ImageSharp.ImageSharpImageSource <SixLabors.ImageSharp.PixelFormats.Rgba32>();


            using (PdfSharpCore.Pdf.PdfDocument document = new PdfSharpCore.Pdf.PdfDocument())
            {
                document.Info.Title    = "Family Tree";
                document.Info.Author   = "FamilyTree Ltd. - Stefan Steiger";
                document.Info.Subject  = "Family Tree";
                document.Info.Keywords = "Family Tree, Genealogical Tree, Genealogy, Bloodline, Pedigree";


                document.ViewerPreferences.Direction = PdfSharpCore.Pdf.PdfReadingDirection.LeftToRight;

                PdfSharpCore.Pdf.PdfPage page = document.AddPage();

                // page.Width = PdfSettings.PaperFormatSettings.Width
                // page.Height = PdfSettings.PaperFormatSettings.Height

                page.Width  = 500;
                page.Height = 1000;

                page.Orientation = PdfSharpCore.PageOrientation.Landscape;


                double mid              = page.Width / 2;
                double textBoxWidth     = 200;
                double halfTextBoxWidth = textBoxWidth / 2;


                using (PdfSharpCore.Drawing.XGraphics gfx = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page))
                {
                    gfx.MUH = PdfSharpCore.Pdf.PdfFontEncoding.Unicode;

                    PdfSharpCore.Drawing.Layout.XTextFormatter tf = new PdfSharpCore.Drawing.Layout.XTextFormatter(gfx);
                    tf.Alignment = PdfSharpCore.Drawing.Layout.XParagraphAlignment.Left;

                    PdfSharpCore.Drawing.Layout.XTextFormatterEx2 etf = new PdfSharpCore.Drawing.Layout.XTextFormatterEx2(gfx);


                    string fn = @"C:\Users\username\Pictures\4_Warning_Signs_Of_Instability_In_Russia1.png";
                    // fn = @"C:\Users\username\Pictures\62e867ba-9bb7-40d0-b01f-57f7cc951929.jpg";
                    // DrawImg(fn, gfx, 10, 10);



                    double dblWidth     = 1.0;
                    string strHtmlColor = "#FF00FF";
                    PdfSharpCore.Drawing.XColor LineColor = XColorHelper.FromHtml(strHtmlColor);
                    PdfSharpCore.Drawing.XPen   pen       = new PdfSharpCore.Drawing.XPen(LineColor, dblWidth);


                    double dblX1 = 100;
                    double dblY1 = 100;

                    double dblX2 = 200;
                    double dblY2 = 200;
                    gfx.DrawLine(pen, dblX1, dblY1, dblX2, dblY2);



                    double rectX      = 100;
                    double rectY      = 100;
                    double rectWidth  = 200;
                    double rectHeight = 100;

                    PdfSharpCore.Drawing.XRect rect = new PdfSharpCore.Drawing.XRect(rectX, rectY
                                                                                     , rectWidth, rectHeight
                                                                                     );

                    PdfSharpCore.Drawing.XFont font = new PdfSharpCore.Drawing.XFont("Arial"
                                                                                     , 12.0, PdfSharpCore.Drawing.XFontStyle.Bold
                                                                                     );

                    int    lastFittingChar = 0;
                    double neededHeight    = 0.0;


                    string text = @"I bi dr Gummiboum
U schtah eifach so chli da
So wie jedä Gummiboum 
'sch im Fau aues, woni cha

U i nime d Tage so wie si sii
U si chömed u gö wider verbii
U aues wird anders oder blibt wies isch gsii

Ja i nime d Tage so we si sii
U si chömed u gö wider verbii
Aues wird anders oder blibt wies isch gsii

Ja aues wird anders oder blibt wies isch gsii

I bi dr Gummiboum
U verstoube fängs ä chli
Oh Gummiboum

I bin ä geile huere Gummiboum
öppert mues ne schliesslich sii";

                    etf.PrepareDrawString(text, font, rect, out lastFittingChar, out neededHeight);
                    System.Console.WriteLine(lastFittingChar);
                    System.Console.WriteLine(neededHeight);

                    string foo = text.Substring(0, lastFittingChar);
                    System.Console.WriteLine(foo);


                    tf.DrawString(text
                                  , font
                                  , PdfSharpCore.Drawing.XBrushes.Black
                                  , rect
                                  , PdfSharpCore.Drawing.XStringFormats.TopLeft
                                  );

                    //gfx.DrawRectangle(PdfSharpCore.Drawing.XBrushes.HotPink, rect);
                    gfx.DrawRectangle(pen, rect);
                } // End Using gfx


                byte[] baPdfDocument;

                using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
                {
                    document.Save(ms, false);
                    ms.Flush();

                    // baPdfDocument = new byte[ms.Length];
                    // ms.Seek(0, System.IO.SeekOrigin.Begin);
                    // ms.Read(baPdfDocument, 0, (int)ms.Length);

                    baPdfDocument = ms.ToArray();
                } // End Using ms


                System.IO.File.WriteAllBytes("FamilyTree.pdf", baPdfDocument);
                //document.Save(filename);
            } // End Using document

            System.Console.WriteLine(System.Environment.NewLine);
            System.Console.WriteLine(" --- Press any key to continue --- ");
            System.Console.ReadKey();
        } // End Sub Main
Esempio n. 25
0
        public FileResult GerarRelatorio(int?id)
        {
            using (var doc = new PdfSharpCore.Pdf.PdfDocument()) {
                var page = doc.AddPage();
                page.Size        = PdfSharpCore.PageSize.A4;
                page.Orientation = PdfSharpCore.PageOrientation.Portrait;

                var grafics          = XGraphics.FromPdfPage(page);
                var corFonte         = XBrushes.Black;
                var textFormatter    = new XTextFormatter(grafics);
                var textJustify      = new XTextFormatter(grafics);
                var fonteOrganizacao = new XFont("Times New Roman", 12);
                var fonteTitulo      = new XFont("Times New Roman", 12, XFontStyle.Bold);
                var fonteDesc        = new XFont("Times New Roman", 8, XFontStyle.Bold);
                var titulo           = new XFont("Times New Roman", 10, XFontStyle.Bold);
                var fonteDetalhes    = new XFont("Times New Roman", 7);
                var fonteNegrito     = new XFont("Times New Roman", 12, XFontStyle.Bold);
                var logo             = @"C:\Logo.png";
                var qtdpaginas       = doc.PageCount;


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

                List <ExpedicaoNovoMandado> dados = new List <ExpedicaoNovoMandado>();

                MySqlConnection con = new MySqlConnection();
                con.ConnectionString = c.ConexaoDados();
                con.Open();
                string          data    = DateTime.Now.ToShortDateString();
                MySqlCommand    command = new MySqlCommand("SELECT * FROM expedicaonovomandado  WHERE  Id = '" + id + "'", con);
                MySqlDataReader reader  = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        dados.Add(new ExpedicaoNovoMandado()
                        {
                            Autos    = reader.GetString("Autos"),
                            Contrato = reader.GetInt64("Contrato"),
                            Vara     = reader.GetString("Vara"),
                            Comarca  = reader.GetString("Comarca"),
                            Estado   = reader.GetString("Estado"),
                            Banco    = reader.GetString("Banco"),
                            Reu      = reader.GetString("Reu"),
                            Endereco = reader.GetString("Endereco"),
                            Oab      = reader.GetString("Oab"),
                            Data     = reader.GetString("Data")
                        });;
                    }
                    Console.WriteLine(data);
                }

                for (int i = 0; i < dados.Count; i++)
                {
                    //Imagem todo da pagina
                    XImage imagem = XImage.FromFile(logo);
                    grafics.DrawImage(imagem, 230, 40, 150, 80);

                    var topo =
                        "EXCELENTÍSSIMO SENHOR DOUTOR JUIZ DE DIREITO DA " + dados[i].Vara + " DA " + dados[i].Comarca + " – ESTADO DO " + dados[i].Estado;

                    var dadosAutos =
                        "Autos nº: " + dados[i].Autos + "\n" +
                        "Contrato nº: " + dados[i].Contrato;


                    var texto =
                        "                                 " + dados[i].Banco + ", já qualificada(o) nos autos em epígrafe, " +
                        "que move em face de " + dados[i].Reu + ", também já qualificada(o), por seus advogados que esta subscrevem, vem, " +
                        "respeitosamente perante Vossa Excelência, REQUERER a expedição de novo mandado para o seguinte endereço: " +
                        "" + dados[i].Endereco + ", com o intuito de citar o requerido e apreender o bem, objeto da presente ação. \n \n \n" +
                        "                              Outrossim, requer que todas as intimações dos atos processuais destes autos sejam efetivadas " +
                        "na forma prevista nos artigos 270 e 272 do CPC (Lei 13.105/2015), " +
                        "na pessoa de Cristiane Belinati Garcia Lopes, " + dados[i].Oab + ", independentemente dos demais procuradores constantes nas procurações " +
                        "e substabelecimentos juntados a estes autos, sob pena de nulidade da intimação, conforme previsto no artigo 280 do CPC.\n \n \n" +
                        "                                 Termos em que,\n" +
                        "                                 Pede deferimento.\n" +
                        "                                 Maringá / PR, " + dados[i].Data;


                    var oab =
                        "CRISTIANE BELINATI GARCIA LOPES\n" +
                        dados[i].Oab;

                    var enderecoRodape =
                        "Endereço: Rua João Paulino Vieira Filho, 625, 12º andar – Sala 1201\n" +
                        "Bairro: Zona 01 CEP: 87020-015 - Fone: (44) 3033-9291 / (44) 2103-9291\n" +
                        "Maringa/PR";

                    //Texto do Topo
                    textJustify.Alignment = XParagraphAlignment.Left;
                    XRect rectTopo = new XRect(50, 155, 490, page.Height);
                    textJustify.DrawString(topo, fonteTitulo, corFonte, rectTopo, XStringFormats.TopLeft);

                    //Dados do Contrato
                    textJustify.Alignment = XParagraphAlignment.Left;
                    XRect rectDados = new XRect(50, 230, 490, page.Height);
                    textJustify.DrawString(dadosAutos, fonteNegrito, corFonte, rectDados, XStringFormats.TopLeft);

                    //Dados do Texto
                    textJustify.Alignment = XParagraphAlignment.Justify;
                    XRect rectTexto = new XRect(50, 290, 490, page.Height);
                    textJustify.DrawString(texto, fonteOrganizacao, corFonte, rectTexto, XStringFormats.TopLeft);

                    //Texto OAB
                    textJustify.Alignment = XParagraphAlignment.Center;
                    XRect rectOab = new XRect(50, 625, 490, page.Height);
                    textJustify.DrawString(oab, fonteTitulo, corFonte, rectOab, XStringFormats.TopLeft);

                    textJustify.Alignment = XParagraphAlignment.Center;
                    XRect rectenderecoRodape = new XRect(50, 790, 490, page.Height);
                    textJustify.DrawString(enderecoRodape, fonteDetalhes, corFonte, rectenderecoRodape, XStringFormats.TopLeft);
                }

                using (MemoryStream stream = new MemoryStream()) {
                    var contentType = "application/pdf";
                    doc.Save(stream, false);
                    var nomeArquivo = "Expedicao de Mandado.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));
                }
            }
        }
Esempio n. 27
0
 public GerarPdfParcela()
 {
     _document = new PdfSharpCore.Pdf.PdfDocument();
 }
Esempio n. 28
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. 29
0
        public static void Test(string textToPrint, string fontDirectory, string outputDirectory)
        {
            char[] textBuffer = textToPrint.ToCharArray();

            PdfSharpCore.Pdf.PdfDocument s_document = null;

            // Create a temporary file
            s_document = new PdfSharpCore.Pdf.PdfDocument();
            s_document.Info.Title = "PDFsharp XGraphic Sample";
            s_document.Info.Author = "Stefan Lange";
            s_document.Info.Subject = "Created with code snippets that show the use of graphical functions";
            s_document.Info.Keywords = "PDFsharp, XGraphics";

            PdfSharpCore.Pdf.PdfPage page = s_document.AddPage();
            
            using (PdfSharpCore.Drawing.XGraphics g = PdfSharpCore.Drawing.XGraphics.FromPdfPage(page))
            {
                g.SmoothingMode = PdfSharpCore.Drawing.XSmoothingMode.HighQuality;
                // g.Clear(System.Drawing.Color.White);
                g.ScaleTransform(1.0F, -1.0F); // Flip the Y-Axis 
                g.TranslateTransform(0.0F, -(float) 500); // Translate the drawing area accordingly   


                DevPdfTextPrinter _currentTextPrinter = new DevPdfTextPrinter();
                _currentTextPrinter.ScriptLang = new ScriptLang(ScriptTagDefs.Thai.Tag);
                _currentTextPrinter.Typeface = Helpers.FontHelper.GetTestTypeface(fontDirectory);
                _currentTextPrinter.FontSizeInPoints = 32;
                _currentTextPrinter.FillBackground = true;
                _currentTextPrinter.DrawOutline = false;

                //-----------------------  
                _currentTextPrinter.HintTechnique = HintTechnique.None;
                _currentTextPrinter.PositionTechnique = PositionTechnique.None;
                _currentTextPrinter.TargetGraphics = g;
                //render at specific pos
                int lineSpacingPx = (int) System.Math.Ceiling(_currentTextPrinter.FontLineSpacingPx);
                float x_pos = 0, y_pos = y_pos = lineSpacingPx * 2; //start 1st line


                //test draw multiple lines

                for (int i = 0; i < 3; ++i)
                {
                    _currentTextPrinter.DrawString(
                        textBuffer,
                        0,
                        textBuffer.Length,
                        x_pos,
                        y_pos
                    );
                    //draw top to bottom 
                    y_pos -= lineSpacingPx;
                }

                //transform back
                g.ScaleTransform(1.0F, -1.0F); // Flip the Y-Axis 
                g.TranslateTransform(0.0F, -(float) 500); // Translate the drawing area accordingly            
            } // End Using g 


            outputDirectory = System.IO.Path.Combine(outputDirectory, "FontRendering.pdf");
            s_document.Save(outputDirectory);
        } // End Sub Test