示例#1
0
        protected void voucherPDF(List <vendacliente> pVendaCliente)
        {
            var document      = new PdfDocument();
            var page          = document.AddPage();
            var graphics      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
            var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
            var font          = new PdfSharp.Drawing.XFont("Calibri", 12);
            var fontColuna    = new PdfSharp.Drawing.XFont("Calibri", 14);


            int y = 55;

            textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
            textFormatter.DrawString("Voucher ", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Destino: " + ddlViagem.SelectedItem.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(200, y, page.Width - 60, page.Height - 60));

            y = y + 40;
            textFormatter.DrawString("Cliente", fontColuna, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Faixa Etaria", fontColuna, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(200, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Assento", fontColuna, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(300, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Valor Pago", fontColuna, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(370, y, page.Width - 60, page.Height - 60));
            y = y + 5;
            decimal ValorTotal = 0;

            foreach (var item in pVendaCliente)
            {
                ValorTotal += item.VendaValorPago;
                y           = y + 30;
                textFormatter.DrawString(SvcCliente.BuscarCliente(item.VendaIdCliente).Nome, font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, y, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(item.FaixaEtaria, font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(200, y, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(item.Assento.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(300, y, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(item.VendaValorPago.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(370, y, page.Width - 60, page.Height - 60));
            }
            textFormatter.DrawString("Valor Total: " + ValorTotal.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(100, 50 + y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Autorizado por: ____________________________________ ", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(100, 100 + y, page.Width - 60, page.Height - 60));

            PdfSharp.Drawing.XRect  layoutRectangle = new PdfSharp.Drawing.XRect(0 /*X*/, page.Height - font.Height /*Y*/, page.Width /*Width*/, font.Height /*Height*/);
            PdfSharp.Drawing.XBrush brush           = PdfSharp.Drawing.XBrushes.Black;
            string noPages = document.Pages.Count.ToString();

            for (int i = 0; i < document.Pages.Count; ++i)
            {
                graphics.DrawString(
                    "Page " + (i + 1).ToString() + " of " + noPages,
                    font,
                    brush,
                    layoutRectangle,
                    PdfSharp.Drawing.XStringFormats.Center);

                graphics.DrawString(
                    "Data: " + DateTime.Now,
                    font,
                    brush,
                    layoutRectangle,
                    PdfSharp.Drawing.XStringFormats.TopLeft);
            }

            document.Save("Vendas.pdf");
            System.Diagnostics.Process.Start("chrome.exe", "Vendas.pdf");
        }
示例#2
0
        //PDFSharp - less features but same company as MigraDoc
        public PdfDocument ConvertToPdf2(ArrayList translationInput, int caseNumber, int evidenceNumber)
        {
            PdfDocument document = new PdfDocument();

            document.Info.Title = "Decrypted Translations";

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

            XGraphics gfx = XGraphics.FromPdfPage(page);

            XFont font = new XFont("Verdna", 11, XFontStyle.Regular);

            var    formatter = new PdfSharp.Drawing.Layout.XTextFormatter(gfx);
            var    rectangle = new XRect(10, 10, page.Width, page.Height);
            string newText   = "";
            //string newText2 = "";
            int i = 0;

            foreach (string text in translationInput)
            {
                i++;
                Console.WriteLine(i + " " + text);
                newText = newText + i + ". " + text + "\r\n";
            }
            formatter.DrawString(newText, font, XBrushes.Black, rectangle);

            string filename = "CsNum" + caseNumber + ".EviNum" + evidenceNumber + ".pdf";

            document.Save(filename);
            //Process.Start(filename);

            return(document);
        }
示例#3
0
        static void Main(string[] args)
        {
            using (var doc = new PdfSharp.Pdf.PdfDocument())
            {
                var page         = doc.AddPage();
                var graphics     = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                var textFormater = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                var font         = new PdfSharp.Drawing.XFont("Arial", 14, PdfSharp.Drawing.XFontStyle.BoldItalic);

                // Acrescentando Textos.
                textFormater.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                textFormater.DrawString("Testando PdfSharp", font, PdfSharp.Drawing.XBrushes.Red, new PdfSharp.Drawing.XRect(0, 50, page.Width, page.Height));

                // Desenhando figuras geometricas.
                graphics.DrawLine(PdfSharp.Drawing.XPens.Blue, 150, 150, 200, 200);
                graphics.DrawRoundedRectangle(PdfSharp.Drawing.XPens.Green, PdfSharp.Drawing.XBrushes.LightBlue, 100, 300, 100, 50, 10, 10);

                // Inserindo uma imagen
                graphics.DrawImage(PdfSharp.Drawing.XImage.FromFile(@"C:\Users\DELL 3470\Google Drive\Mc Molas\Material Grafico - MC Molas\favicon-96x96.PNG"), 250, 300);

                //Gerando o arquivo PDF
                doc.Save("NovoPdf3.pdf");

                //Abrindo o arquivo gerado, com o leitor escolhio por default do sistema.
                System.Diagnostics.Process.Start("NovoPdf3.pdf");
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            using (var doc = new PdfSharp.Pdf.PdfDocument())
            {
                var page          = doc.AddPage();
                var graphics      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);

                var Foto = @"C:\Users\leona\Pictures\IMG_20140412_174325270.jpg";

                graphics.DrawImage(PdfSharp.Drawing.XImage.FromFile($@"{Foto}"), 1, 1, page.Width, page.Height);

                doc.Save("arquivo.pdf");
                System.Diagnostics.Process.Start("arquivo.pdf");


                //Metodo para escrever no pdf
                //var font = new PdfSharp.Drawing.XFont("Arial", 14, PdfSharp.Drawing.XFontStyle.BoldItalic);
                //textFormatter.DrawString("Que belo texto!", font, PdfSharp.Drawing.XBrushes.Red, new PdfSharp.Drawing.XRect(0, 50, page.Width, page.Height));
                //textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;

                //fazer um traçado no pdf
                //graphics.DrawLine(PdfSharp.Drawing.XPens.Blue, 150, 150, 250, 200);

                //fazer um retangulo verde
                //graphics.DrawRoundedRectangle(PdfSharp.Drawing.XPens.Green, PdfSharp.Drawing.XBrushes.LightGreen, 100, 300, 100, 50, 10, 10);
            }
        }
示例#5
0
        private void Button_Click3(object sender, RoutedEventArgs e) //.txt
        {
            //Convert TXT to PDF(PdfSharp, PdfSharp.Charting-wpf)
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.CheckFileExists  = true;
            openFileDialog.Multiselect      = true;
            openFileDialog.Filter           = "Doc files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            Nullable <bool> result = openFileDialog.ShowDialog();

            if (result == true)
            {
                try
                {
                    string line    = null;
                    int    yPoint  = 0;
                    string inpFile = openFileDialog.FileName;
                    string outFile = @"C:\Users\Mariia\Desktop\Convertor\PDFfromTXT.pdf";
                    System.IO.TextReader readFile = new StreamReader(inpFile);
                    PdfDocument          pdf      = new PdfDocument();  // Создаем новый PDF документ
                    pdf.Info.Title = "TXT to PDF";
                    PdfPage   pdfPage = pdf.AddPage();                  // Создаем пустую страницу
                    XGraphics graph   = XGraphics.FromPdfPage(pdfPage); // Получаем объект XGraphics для "рисования" элементов на странице
                                                                        //  XTextFormatter graph = XTextFormatter.FromPdfPage(pdfPage);
                    PdfSharp.Drawing.Layout.XTextFormatter measure = new PdfSharp.Drawing.Layout.XTextFormatter(graph);
                    // Специальная опция для шрифта. Это чтобы русский текст нормально отображался
                    XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always); // в фоксіт не змінилося
                    XFont           font    = new XFont("Verdana", 12, XFontStyle.Regular, options);                 // Создаем шрифт
                    while (true)
                    {
                        line = readFile.ReadLine();
                        if (line == null)
                        {
                            break; // TODO: might not be correct. Was : Exit While
                        }
                        else
                        {
                            //XRect class to create rectangles for elements to sit within.
                            measure.DrawString(line, font, XBrushes.Black,
                                               new XRect(30, yPoint + 30, pdfPage.Width.Point - 50, pdfPage.Height.Point - 30), XStringFormats.TopLeft);//  XRect(зліва, зверху, справа, знизу)
                            //yPoint = yPoint + 30;
                        }
                    }
                    //string pdfFilename = @"D:\Desktop\1ДЗ\Курсач\d3 (1)\d3\d\d\dokum\test.pdf"; // Сохраняем файл
                    pdf.Save(outFile);
                    readFile.Close();
                    readFile = null;
                    Process.Start(outFile); // запускам сразу в программе просмотра pdf файлов
                }
                //yhhyhy
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            ////// картинка
            ////gfx.DrawImage(XImage.FromFile("путь до картинки\\1.jpg"), 110, 10);
        }
示例#6
0
        private void BtnGerar_Click(object sender, EventArgs e)
        {
            int h = 50;
            int w = 5;

            using (var doc = new PdfSharp.Pdf.PdfDocument())
            {
                var page = doc.AddPage();
                page.Size = PdfSharp.PageSize.A4;
                var graphics      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                var font          = new PdfSharp.Drawing.XFont("Arial", 12);

                var titleFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                titleFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                titleFormatter.DrawString("Relatório de Gastos", font, PdfSharp.Drawing.XBrushes.Red, new PdfSharp.Drawing.XRect(0, 0, page.Width, page.Height));

                var descricao = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                descricao.DrawString("Descrição", font, PdfSharp.Drawing.XBrushes.Red, new PdfSharp.Drawing.XRect(0, 25, page.Width, page.Height));

                var tipo = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                tipo.DrawString("Tipo", font, PdfSharp.Drawing.XBrushes.Red, new PdfSharp.Drawing.XRect(175, 25, page.Width, page.Height));

                var val = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                val.DrawString("Valor", font, PdfSharp.Drawing.XBrushes.Red, new PdfSharp.Drawing.XRect(300, 25, page.Width, page.Height));

                var data = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                data.DrawString("Data", font, PdfSharp.Drawing.XBrushes.Red, new PdfSharp.Drawing.XRect(400, 25, page.Width, page.Height));

                for (int i = 0; i < this.dgvRelatorio.RowCount; i++)
                {
                    w = 0;
                    string[] valor = new string[4];
                    valor[0] = this.dgvRelatorio.Rows[i].Cells[0].Value.ToString();
                    valor[1] = this.dgvRelatorio.Rows[i].Cells[1].Value.ToString();
                    valor[2] = this.dgvRelatorio.Rows[i].Cells[2].Value.ToString();
                    valor[3] = this.dgvRelatorio.Rows[i].Cells[3].Value.ToString();
                    textFormatter.DrawString(valor[0], font, PdfSharp.Drawing.XBrushes.Black,
                                             new PdfSharp.Drawing.XRect(0, h, page.Width, page.Height));
                    textFormatter.DrawString(valor[1], font, PdfSharp.Drawing.XBrushes.Black,
                                             new PdfSharp.Drawing.XRect(w += 175, h, page.Width, page.Height));
                    textFormatter.DrawString(valor[2], font, PdfSharp.Drawing.XBrushes.Black,
                                             new PdfSharp.Drawing.XRect(w += 125, h, page.Width, page.Height));
                    textFormatter.DrawString(valor[3], font, PdfSharp.Drawing.XBrushes.Black,
                                             new PdfSharp.Drawing.XRect(w += 100, h, page.Width, page.Height));
                    h += 20;
                }
                doc.Save("pdf.pdf");
                System.Diagnostics.Process.Start("pdf.pdf");
            }
        }
示例#7
0
        public static void EscreverPDF(string nome, string Texto)
        {
            using (var doc = new PdfSharp.Pdf.PdfDocument())
            {
                var page          = doc.AddPage();
                var graphics      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                var font          = new PdfSharp.Drawing.XFont("Arial", 14);

                textFormatter.DrawString(Texto, font, PdfSharp.Drawing.XBrushes.Red, new PdfSharp.Drawing.XRect(50, 50, page.Width, page.Height));

                doc.Save(nome);
                System.Diagnostics.Process.Start(nome);
            }
        }
示例#8
0
        public void Converter(string LocalArquivo, string LocalSalvar, string NomeArquivo)
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            var Dados = File.ReadAllText(LocalArquivo);

            using (var doc = new PdfSharp.Pdf.PdfDocument())
            {
                var page          = doc.AddPage();
                var graphics      = XGraphics.FromPdfPage(page);
                var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                textFormatter.DrawString(Dados, new XFont("Arial", 9),
                                         XBrushes.Black,
                                         new XRect(0, 0, page.Width, page.Height));

                doc.Save(LocalSalvar + "\\" + NomeArquivo + ".pdf");
            }
        }
示例#9
0
        private void btnPDF_Click(object sender, EventArgs e)
        {
            try
            {
                using (var doc = new PdfSharp.Pdf.PdfDocument())
                {
                    var page          = doc.AddPage();
                    var graphics      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                    var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                    var font          = new PdfSharp.Drawing.XFont("Arial", 10);
                    int cont          = up.listarTodos().Rows.Count;
                    /*cont = 2;*/
                    int   posicaoY = 20;
                    int[] posicaoX = { 20, 25, 90, 160, 260, 340, 390 };
                    for (int i = 0; i < cont - 1; i++)
                    {
                        for (int j = 0; j < 7; j++)
                        {
                            /*if (i == cont)
                             *  break;*/
                            textFormatter.DrawString(up.listarTodos().Rows[i][j].ToString(), font, PdfSharp.Drawing.XBrushes.Red, new PdfSharp.Drawing.XRect(posicaoX[j], posicaoY, page.Width, page.Height));
                        }
                        posicaoY += 10;

                        /*if (i == cont)
                         *  break;*/
                    }
                    doc.Save("arquivo.pdf");
                    System.Diagnostics.Process.Start("arquivo.pdf");
                }
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }

            /*  Document documento = new Document(PageSize.A4, 5, 5, 15, 15);
             * PdfWriter.GetInstance(documento, new Fil(HttpContext.Current.Server.MapPath("~/documento.pdf"), FileMode.Create));
             * documento.Open();
             * // cria tablela de 4 coluna
             * PdfPTable tabela = new PdfPTable(4);
             * // cria uma célula - será usada para cada célula abaixo
             *
             * PdfPCell celula = new PdfPCell();*/
        }
示例#10
0
        public static async Task EnviarMailAsync(List <String> mensagem, string para)
        //public ActionResult Contact(vmFormularioEmail model)
        {
            using (var doc = new PdfSharp.Pdf.PdfDocument())
            {
                var page          = doc.AddPage();
                var graphics      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                var font          = new PdfSharp.Drawing.XFont("Arial", 14);

                int i = 0;
                foreach (String m in mensagem)
                {
                    textFormatter.DrawString(m + "\n", font, PdfSharp.Drawing.XBrushes.Red, new PdfSharp.Drawing.XRect(0, i, page.Width, page.Height));
                    i += 20;
                }

                doc.Save(AppDomain.CurrentDomain.BaseDirectory + "mail2.pdf");
                doc.Close();

                var message = new MailMessage();
                message.To.Add(new MailAddress(para));                   //Destinatário
                message.From    = new MailAddress("*****@*****.**"); //Remetente
                message.Subject = "Suporte do Site de Eventos";
                message.Attachments.Add(new Attachment(AppDomain.CurrentDomain.BaseDirectory + "mail.pdf"));

                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // Seu E-mail
                        Password = "******"                 // Sua Senha
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;

                    await smtp.SendMailAsync(message);
                }
            }
        }
示例#11
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                aluguel_bancoEntities3 bd = new aluguel_bancoEntities3();
                using (var doc = new PdfSharp.Pdf.PdfDocument())
                {
                    int distancia = 150;

                    var page          = doc.AddPage();
                    var graphicx      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                    var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphicx);
                    var fontTitulo    = new PdfSharp.Drawing.XFont("Arial", 16);
                    var font          = new PdfSharp.Drawing.XFont("Arial", 12);

                    textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                    textFormatter.DrawString("Relatório Geral\n \n \n", fontTitulo, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 70, page.Width, page.Height));
                    textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Justify;
                    textFormatter.DrawString(" Descrição", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 120, 250, 145));
                    textFormatter.DrawString(" Data", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(255, 120, 320, 145));
                    textFormatter.DrawString(" Valor Pago", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(345, 120, 420, 145));
                    textFormatter.DrawString(" Saldo do Devedor", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(445, 120, 590, 145));

                    bd.apartamentos_tabela.ToList().ForEach(ap =>
                    {
                        textFormatter.DrawString(ap.descricao, font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, distancia, 250, distancia + 25));
                        textFormatter.DrawString(Convert.ToString(ap.data_compra.Value.ToString("dd/MM/yyyy")), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(255, distancia, 320, distancia + 25));
                        textFormatter.DrawString("R$" + Convert.ToString(Math.Round(ap.valor_pago_reais, 2)), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(345, distancia, 420, distancia + 25));
                        textFormatter.DrawString("R$" + Convert.ToString(Math.Round(Convert.ToDouble(ap.saldo_devedor_cub) * valorCub, 2)), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(445, distancia, 590, distancia + 25));
                        distancia += 30;
                    });
                    graphicx.DrawLine(PdfSharp.Drawing.XPens.Black, 250, 130, 250, distancia);
                    graphicx.DrawLine(PdfSharp.Drawing.XPens.Black, 340, 130, 340, distancia);
                    graphicx.DrawLine(PdfSharp.Drawing.XPens.Black, 440, 130, 440, distancia);
                    doc.Save("arquivo.pdf");
                    System.Diagnostics.Process.Start("arquivo.pdf");
                }
            }
            catch
            {
                MessageBox.Show("Erro ao gerar PDF");
            }
        }
        public void Converter()
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            //var xmlInputData = File.ReadAllText(@"D:\EHSSitemas\Niveus\ConverterAquivoPDF\JANEIRO2018.ofc",Encoding.UTF8);
            var          xmlInputData = File.ReadAllText("JANEIRO2018.ofc");
            StreamReader streamReader = new StreamReader(@"D:\EHSSitemas\Niveus\ConverterAquivoPDF\JANEIRO2018.ofc");
            var          aqruivo      = streamReader.ReadToEnd();

            // C#
            using (var doc = new PdfSharp.Pdf.PdfDocument())
            {
                var page          = doc.AddPage();
                var graphics      = XGraphics.FromPdfPage(page);
                var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                textFormatter.DrawString(xmlInputData, new XFont("Arial", 10),
                                         XBrushes.Black,
                                         new XRect(0, 0, page.Width, page.Height));

                doc.Save("arquivo.pdf");
            }
        }
示例#13
0
 /// <summary>Add a new page if the current page is not empty</summary>
 public void addPage()
 {
     if (!_isPageEmpty)
     {
         if (_pageCount != 0)
         {
             addPagenumber();
         }
         _page = new PdfSharp.Pdf.PdfPage();
         if (_pageCount == 0)
         {
             _size.Width  = _page.Width;
             _size.Height = _page.Height;
             _area        = new PdfSharp.Drawing.XRect {
                 X      = PdfSharp.Drawing.XUnit.FromMillimeter(10),
                 Y      = PdfSharp.Drawing.XUnit.FromMillimeter(10),
                 Width  = _page.Width - PdfSharp.Drawing.XUnit.FromMillimeter(20),
                 Height = _page.Height - PdfSharp.Drawing.XUnit.FromMillimeter(45)
             };
         }
         else
         {
             _page        = new PdfSharp.Pdf.PdfPage();
             _page.Width  = _size.Width;
             _page.Height = _size.Height;
         }
         _horizontalePosition = _area.X;
         _verticalPosition    = _area.Y;
         _doc.AddPage(_page);
         if (_graphics != null)
         {
             _graphics.Dispose();
         }
         _graphics     = PdfSharp.Drawing.XGraphics.FromPdfPage(_page);
         _textformater = new PdfSharp.Drawing.Layout.XTextFormatter(_graphics);
         _pageCount++;
         _isPageEmpty = true;
     }
 }
示例#14
0
        public byte[] GetPdfFile()
        {
            var document = new PdfDocument();
            var prints   = this.GetPrintImage();

            foreach (var print in prints)
            {
                var page = document.AddPage();
                using (var graphics = XGraphics.FromPdfPage(page))
                {
                    graphics.SmoothingMode = XSmoothingMode.HighQuality;
                    var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                    var stream        = new MemoryStream();
                    print.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                    graphics.DrawImage(XImage.FromStream(stream), 0, 0, page.Width, page.Height);
                }
            }
            ;
            var pdfStream = new MemoryStream();

            document.Save(pdfStream, true);
            return(pdfStream.ToArray());
        }
示例#15
0
        //MÉTODOS
        private void geradorPDF()
        {
            using (var doc = new PdfSharp.Pdf.PdfDocument())
            {
                var page          = doc.AddPage();
                var graphics      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                var textformatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);

                var font  = new PdfSharp.Drawing.XFont("Arial", 14);
                var font2 = new PdfSharp.Drawing.XFont("Arial", 22);
                //NEGRITO FONTE
                var font3 = new PdfSharp.Drawing.XFont("Arial", 14, PdfSharp.Drawing.XFontStyle.Bold);
                var font4 = new PdfSharp.Drawing.XFont("Arial", 22, PdfSharp.Drawing.XFontStyle.Bold);

                //NOME
                textformatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                textformatter.DrawString(txtNome.Text, font4, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 40, page.Width, page.Height));
                //ENDEREÇO
                textformatter.DrawString("Rua " + txtRua.Text + ", " + txtNumeroRua.Text + " - " +
                                         txtBairro.Text + " - " +
                                         txtCidade.Text + " - " + cbbEstado.Text + " - CEP: " + txtCep.Text,
                                         font, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 80, page.Width, page.Height));
                //CONTATOS
                textformatter.DrawString("Telefone: " + txtTelefone.Text + " Celular: " + txtCelular.Text,
                                         font, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 110, page.Width, page.Height));

                textformatter.DrawString("E-mail: " + txtEmail.Text, font, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 140, page.Width, page.Height));
                //ESTADO CIVIL E IDADE
                textformatter.DrawString("Idade: " + txtIdade.Text + " - Estado Civil: " + cbbEstadoCivil.Text
                                         + " - Sexo: " + cbbSexo.Text,
                                         font, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 170, page.Width, page.Height));
                //GENERO, FILHOS E NACIONALIDADE
                textformatter.DrawString("Filhos: " +
                                         cbbFilhos.Text + " - Nacionalidade: " + txtNacionalidade.Text,
                                         font, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 200, page.Width, page.Height));
                //OBJETIVO
                textformatter.DrawString("Objetivo: " + txtObjetivo.Text, font3, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 225, page.Width, page.Height));
                //FORMAÇÃO ACADÊMICA
                textformatter.DrawString("Formação Acadêmica", font4, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 330, page.Width, page.Height));
                //ESCOLARIDADE
                textformatter.DrawString("Escolaridade: " + cbbEscolaridade.Text + " - " + txtInstituicaoEscola.Text,
                                         font, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 365, page.Width, page.Height));

                textformatter.DrawString("Horário: " + cbbHorarioEscola.Text +
                                         " - Ano de Término (Previsão de Término): " + txtAnoEscola.Text,
                                         font, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 380, page.Width, page.Height));

                textformatter.DrawString(txtCursos.Text,
                                         font, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 405, page.Width, page.Height));
                //EXPERIÊNCIA profissional
                textformatter.DrawString("Experiência Profissional", font4, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 500, page.Width, page.Height));

                textformatter.DrawString(txtExperiencia.Text,
                                         font, PdfSharp.Drawing.XBrushes.Black,
                                         new PdfSharp.Drawing.XRect(0, 525, page.Width, page.Height));
                try
                {
                    doc.Save("arquivo.pdf");
                    System.Diagnostics.Process.Start("arquivo.pdf");
                }
                catch (Exception Erro)
                {
                    MessageBox.Show("Erro: " + Erro,
                                    "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#16
0
        static void WriteTest()
        {
            using (PdfSharp.Pdf.PdfDocument document = new PdfSharp.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";


                PdfSharp.Pdf.Security.PdfSecuritySettings securitySettings = document.SecuritySettings;

                // Setting one of the passwords automatically sets the security level to
                // PdfDocumentSecurityLevel.Encrypted128Bit.
                securitySettings.UserPassword  = "******";
                securitySettings.OwnerPassword = "******";

                // Don't use 40 bit encryption unless needed for compatibility
                //securitySettings.DocumentSecurityLevel = PdfDocumentSecurityLevel.Encrypted40Bit;

                // Restrict some rights.
                securitySettings.PermitAccessibilityExtractContent = false;
                securitySettings.PermitAnnotations      = false;
                securitySettings.PermitAssembleDocument = false;
                securitySettings.PermitExtractContent   = false;
                securitySettings.PermitFormsFill        = true;
                securitySettings.PermitFullQualityPrint = false;
                securitySettings.PermitModifyDocument   = true;
                securitySettings.PermitPrint            = false;



                document.ViewerPreferences.Direction = PdfSharp.Pdf.PdfReadingDirection.LeftToRight;
                PdfSharp.Pdf.PdfPage page = document.AddPage();

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

                page.Orientation = PdfSharp.PageOrientation.Landscape;
                double dblLineWidth = 1.0;
                string strHtmlColor = "#FF00FF";
                PdfSharp.Drawing.XColor lineColor = XColorHelper.FromHtml(strHtmlColor);
                PdfSharp.Drawing.XPen   pen       = new PdfSharp.Drawing.XPen(lineColor, dblLineWidth);

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



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

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

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


                    gfx.DrawRectangle(pen, new PdfSharp.Drawing.XRect(100, 100, 100, 100));

                    using (PdfSharp.Drawing.XImage img = PdfSharp.Drawing.XImage.FromFile(@"D:\username\Documents\Visual Studio 2017\Projects\PdfSharp\TestApplication\Wikipedesketch1.png"))
                    {
                        gfx.DrawImage(img, 500, 500);
                    }

                    string text = "Lalala";

                    tf.DrawString(text
                                  , font
                                  , PdfSharp.Drawing.XBrushes.Black
                                  , new PdfSharp.Drawing.XRect(300, 300, 100, 100)
                                  , PdfSharp.Drawing.XStringFormats.TopLeft
                                  );
                } // End Using gfx

                // Save the document...
                string filename = "TestFilePwProtected.pdf";
                document.Save(filename);
                // ...and start a viewer.
                System.Diagnostics.Process.Start(filename);
            } // End Using document
        }     // End Sub WriteTest
示例#17
0
        public static void CriarPDFRecibo(string txtcliente, string txtEndereco, string txtimportancia, string txtreferente)
        {
            // C#
            using (var doc = new PdfSharp.Pdf.PdfDocument())
            {
                //var NomeCliente = nome;
                //var DadosCliente = new CLIENTEDAL().CONSULTATODOSPELONOME(NomeCliente);

                decimal valor = Convert.ToDecimal(txtimportancia);
                var     TextoValorExtersom = EscreverExtenso(valor);

                var page          = doc.AddPage();
                var graphics      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                var font          = new PdfSharp.Drawing.XFont("Arial", 14);
                var fontRecibo    = new PdfSharp.Drawing.XFont("Microsoft Sans Serif", 30);
                var fontTexto     = new PdfSharp.Drawing.XFont("Arial", 12, PdfSharp.Drawing.XFontStyle.Underline);

                // Imagem.
                var caminho = Application.StartupPath + "\\Pegasus.png";
                graphics.DrawImage(PdfSharp.Drawing.XImage.FromFile(caminho), 0, 30, 200, 100);


                // C#
                // Textos.
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                textFormatter.DrawString("RECIBO", fontRecibo, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(60, 30, page.Width - 60, page.Height - 60));

                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                textFormatter.DrawString("Valor", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(60, 60, page.Width - 60, page.Height - 60));
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                textFormatter.DrawString(valor.ToString("C"), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(60, 80, page.Width - 60, page.Height - 60));

                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString("Recebi (emos) de: ", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 150, page.Width - 60, page.Height - 60));
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString(txtcliente.ToString(), fontTexto, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(150, 150, page.Width - 60, page.Height - 60));


                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString("Endereço: ", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 170, page.Width - 60, page.Height - 60));
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString(txtEndereco.ToString(), fontTexto, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(100, 170, page.Width - 60, page.Height - 60));

                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString("A importancia de: ", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 190, page.Width - 60, page.Height - 60));
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString(TextoValorExtersom.ToString(), fontTexto, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(150, 190, page.Width - 60, page.Height - 60));

                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString("Referente: ", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 210, page.Width - 60, page.Height - 60));
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString(txtreferente.ToString(), fontTexto, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(100, 210, page.Width - 60, page.Height - 60));

                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                textFormatter.DrawString("Por ser verdade, firmo o presente.", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 300, page.Width - 60, page.Height - 60));

                //desmenbrando a data
                CultureInfo        culture = new CultureInfo("pt-BR");
                DateTimeFormatInfo dtfi    = culture.DateTimeFormat;

                int    dia        = DateTime.Now.Day;
                int    ano        = DateTime.Now.Year;
                string mes        = culture.TextInfo.ToTitleCase(dtfi.GetMonthName(DateTime.Now.Month));
                string diasemana  = culture.TextInfo.ToTitleCase(dtfi.GetDayName(DateTime.Now.DayOfWeek));
                string DataRecibo = "Manaus, AM, " + dia + " de " + mes + " de " + ano;

                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Right;
                textFormatter.DrawString(DataRecibo, font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 320, page.Width - 60, page.Height - 60));


                //para processo do programa pdf acrobat
                #region Ferificando o programa pdf Acrobat
                Process[] macProcessos;
                macProcessos = Process.GetProcessesByName(Application.StartupPath + @"\ReciboGErado.pdf");
                if (macProcessos.Length == 1)
                {
                    //processo estar sendo executado
                    foreach (Process processo in macProcessos)
                    {
                        processo.CloseMainWindow();
                    }
                }
                #endregion
                //para processo do programa pdf acrobat
                #region Ferificando o programa pdf Acrobat
                macProcessos = Process.GetProcessesByName("AcroRd32.exe");
                if (macProcessos.Length == 1)
                {
                    //processo estar sendo executado
                    foreach (Process processo in macProcessos)
                    {
                        processo.CloseMainWindow();
                    }
                }
                #endregion

                //salva
                doc.Save("ReciboGErado.pdf");
                //System.Diagnostics.Process.Start("Recibo.pdf");
            }
        }
示例#18
0
        public static FileStreamResult GerarPdfEmpenho(ConsultaNe consulta, string tipo, Model.Entity.Empenho.Empenho empenho)
        {
            #region Configuraçao

            var meses = new List <mes>();

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

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

                    i += 1;
                }
            }

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


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

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

            FileInfo newFile = new FileInfo(file);

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

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

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

            double val    = 0;
            double espaco = 25;

            var diretorio = GerarImagem();

            #endregion

            #region Cabeçario

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

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

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

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


            #endregion

            #region Bloco1


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

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

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

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

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

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



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

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


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

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

            #endregion

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

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

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

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

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

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

            #endregion

            #region Bloco3

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

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

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


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

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


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

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

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


            #endregion

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

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

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

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

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

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


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

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

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

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


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

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

            #endregion

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

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



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

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

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

            #endregion

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

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

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

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


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

            #endregion

            #region Bloco6

            linha += pularLinha * 3;

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

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


            #endregion


            #region Bloco7



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

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



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


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


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


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


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


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


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


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


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


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


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


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

            #endregion


            #region bloco8



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

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


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

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


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

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


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

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

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

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


            #endregion

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

            var contentType = "application/pdf";

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

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

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

            return(fsr);
        }
示例#19
0
        private async void button2_Click(object sender, EventArgs e)
        {
            client = new FireSharp.FirebaseClient(config);
            if (!nameBox.Text.Equals(null) || !unameBox.Text.Equals(null) || !passBox1.Text.Equals(null) || !passBox2.Text.Equals(null) || !hstudyBox.Text.Equals(null) || !desigBox.Text.Equals(null) || !phnBox.Text.Equals(null) || !mailBox.Text.Equals(null) || !idBox.Text.Equals(null) || deptCBox.SelectedIndex == -1 || sessionBox.SelectedIndex == -1 || pictureBox1.Image == null)
            {
                if (passBox1.Text.Equals(passBox2.Text))
                {
                    StudentData d = new StudentData();
                    d.id   = hstudyBox.Text;
                    d.pass = passBox1.Text;
                    SetResponse res = null;
                    if (uType.Equals("Student"))
                    {
                        res = await client.SetTaskAsync("Student" + "Login/" + sessionBox.SelectedItem.ToString() + "/" + ch3 + unameBox.Text, d);
                    }
                    else if (uType.Equals("Alumni"))
                    {
                        AlumniData d1 = new AlumniData();
                        d1.name     = nameBox.Text;
                        d1.id       = idBox.Text;
                        d1.pass     = passBox1.Text;
                        d1.hStudy   = hstudyBox.Text;
                        d1.desig    = desigBox.Text;
                        d1.pAddrees = paddressBox.Text;
                        d1.phn      = phnBox.Text;
                        d1.mailid   = mailBox.Text;

                        String picSource = "D://3-1//Project c#//StudentTeacher//picSource//" + unameBox.Text + sessionBox.SelectedItem.ToString() + ".jpg";
                        d1.picid = picSource;
                        res      = await client.SetTaskAsync("AlumniLogin/" + ch3 + "/" + sessionBox.SelectedItem.ToString() + "/" + unameBox.Text, d1);


                        File.Delete(picSource);
                        //MessageBox.Show(imgLoc + "  " + picSource);
                        System.IO.File.Copy(imgLoc, picSource);

                        //MessageBox.Show(imgLoc+"  "+picSource);



                        String text = "\nName: " + nameBox.Text + "\nId: " + idBox.Text + "\nHigher Study Info: " + hstudyBox.Text + "\nDesignation: " + desigBox.Text + "\nPressent Address: " + paddressBox.Text + "\nContact No.: " + phnBox.Text + "\nEmai: " + mailBox.Text + "\nDepartment: " + deptCBox.SelectedItem.ToString() + "\nSession: " + sessionBox.SelectedItem.ToString();
                        PdfSharp.Pdf.PdfDocument document = new PdfSharp.Pdf.PdfDocument();
                        PdfSharp.Pdf.PdfPage     page     = document.AddPage();
                        XGraphics gfx  = XGraphics.FromPdfPage(page);
                        XFont     font = new XFont("Times New Roman", 10, XFontStyle.Bold);
                        PdfSharp.Drawing.Layout.XTextFormatter tf = new PdfSharp.Drawing.Layout.XTextFormatter(gfx);

                        XRect rect = new XRect(40, 100, 250, 220);
                        gfx.DrawRectangle(XBrushes.SeaShell, rect);
                        tf.DrawString(text, font, XBrushes.Black, rect, XStringFormats.TopLeft);


                        string pdfFilename = "D://3-1//Project c#//StudentTeacher//pdfSource//" + sessionBox.SelectedItem.ToString() + unameBox.Text + ".pdf";
                        document.Save(pdfFilename);
                        Process.Start(pdfFilename);



                        if (d1.pass.Equals(passBox1.Text))
                        {
                            MessageBox.Show("Registration Successfull..");
                            this.Hide();
                        }
                    }

                    else if (uType.Equals("Teacher"))
                    {
                        res = await client.SetTaskAsync(uType + "Login/" + unameBox.Text, d);
                    }
                }
                else
                {
                    MessageBox.Show("Passwords Are Not Identical..");
                }
            }
            else
            {
                MessageBox.Show("Some Fields are Not yet Filled or Selected....");
            }
        }
示例#20
0
        //public static FileStreamResult CreatePdf(Fatura f)
        //{
        //    var pdf = GerarFatura(f);

        //    var stream = new MemoryStream();

        //    pdf.Save(stream, true);


        //    return new FileStreamResult(stream, "application/pdf");
        //}

        public static MemoryStream GerarFatura(Fatura f)
        {
            var stream = new MemoryStream();

            using (var doc = new PdfDocument())
            {
                #region Configuracao de pagina
                var pagina = doc.AddPage();
                pagina.Size               = PdfSharp.PageSize.A4;
                pagina.TrimMargins.Top    = 50;
                pagina.TrimMargins.Bottom = 60;
                pagina.TrimMargins.Right  = 30;
                pagina.TrimMargins.Left   = 30;
                #endregion

                var fontRegular = new XFont("Consolas", 20, XFontStyle.Regular);
                var grafico     = XGraphics.FromPdfPage(pagina);
                var formatacao  = new PdfSharp.Drawing.Layout.XTextFormatter(grafico);

                #region Conteudo
                var corFonte = XBrushes.Black;
                //Dados da Empresa
                grafico.DrawString(f.Emissor.Nome, new XFont("Consolas", 20, XFontStyle.Bold), corFonte, 180, 40, XStringFormats.Center);
                grafico.DrawString(string.Concat(Constante.CAMPO_CNPJ, f.Emissor.Cnpj), new XFont("Consolas", 10, XFontStyle.Bold), corFonte, 180, 60, XStringFormats.Center);
                grafico.DrawString(string.Join(", ", f.Emissor.Logradouro, f.Emissor.Numero, f.Emissor.Bairro, f.Emissor.Municipio, f.Emissor.Uf), new XFont("Consolas", 8, XFontStyle.BoldItalic), corFonte, 180, 75, XStringFormats.Center);
                grafico.DrawString(string.Concat(Constante.CAMPO_CEP, f.Emissor.Cep, " ", Constante.CAMPO_FONE, f.Emissor.Fone), new XFont("Consolas", 8, XFontStyle.BoldItalic), corFonte, 180, 85, XStringFormats.Center);


                //Dados da Fatura
                int alinhamento = 360;
                grafico.DrawString(Constante.DESC_MODELO, new XFont("Consolas", 10, XFontStyle.Bold), corFonte, 390, 12);
                grafico.DrawString(Constante.CAMPO_EMISSAO, new XFont("Consolas", 10, XFontStyle.Bold), corFonte, alinhamento, 30);
                grafico.DrawString(f.DataEmissao.ToString("dd/MM/yyyy"), new XFont("Consolas", 10, XFontStyle.Regular), corFonte, 440, 30);

                grafico.DrawString(Constante.CAMPO_INSC_M, new XFont("Consolas", 10, XFontStyle.Bold), corFonte, alinhamento, 50);
                grafico.DrawString(f.Emissor.InscMunicipal, new XFont("Consolas", 10, XFontStyle.Regular), corFonte, 470, 50);

                grafico.DrawString(Constante.CAMPO_NAT_OP, new XFont("Consolas", 10, XFontStyle.Bold), corFonte, alinhamento, 60);
                grafico.DrawString(Constante.NAT_OP, new XFont("Consolas", 10, XFontStyle.Regular), corFonte, 480, 60);

                grafico.DrawString(Constante.SERIE, new XFont("Consolas", 10, XFontStyle.Bold), corFonte, alinhamento, 70);
                grafico.DrawString(Constante.SERIE_TIPO, new XFont("Consolas", 10, XFontStyle.Regular), corFonte, 400, 70);

                grafico.DrawString(string.Concat("Nº: ", f.Numero.ToString("00000")), new XFont("Consolas", 15, XFontStyle.Bold), corFonte, 440, 90);

                //Dados do cliente
                alinhamento = 10;
                grafico.DrawString(Constante.CAMPO_NOME_CLIENTE, new XFont("Consolas", 12, XFontStyle.Bold), corFonte, alinhamento, 120);
                grafico.DrawString(f.Cliente.Nome, new XFont("Consolas", 12, XFontStyle.Regular), corFonte, 120, 120);

                grafico.DrawString(Constante.CAMPO_ENDERECO, new XFont("Consolas", 12, XFontStyle.Bold), corFonte, alinhamento, 135);
                grafico.DrawString(string.Concat(f.Cliente.Logradouro, ", ", f.Cliente.Numero), new XFont("Consolas", 12, XFontStyle.Regular), corFonte, 80, 135);

                grafico.DrawString(Constante.CAMPO_MUNICIPIO, new XFont("Consolas", 12, XFontStyle.Bold), corFonte, alinhamento, 150);
                grafico.DrawString(f.Cliente.Municipio, new XFont("Consolas", 12, XFontStyle.Regular), corFonte, 100, 150);

                grafico.DrawString(Constante.CAMPO_ESTADO, new XFont("Consolas", 12, XFontStyle.Bold), corFonte, 300, 150);
                grafico.DrawString(f.Cliente.Uf, new XFont("Consolas", 12, XFontStyle.Regular), corFonte, 350, 150);

                grafico.DrawString(Constante.CAMPO_CEP, new XFont("Consolas", 12, XFontStyle.Bold), corFonte, 400, 150);
                grafico.DrawString(f.Cliente.Cep, new XFont("Consolas", 12, XFontStyle.Regular), corFonte, 440, 150);

                grafico.DrawString(Constante.CAMPO_CNPJ, new XFont("Consolas", 12, XFontStyle.Bold), corFonte, alinhamento, 165);
                grafico.DrawString(f.Cliente.Cnpj, new XFont("Consolas", 12, XFontStyle.Regular), corFonte, 50, 165);

                grafico.DrawString(Constante.CAMPO_INSC_M, new XFont("Consolas", 12, XFontStyle.Bold), corFonte, 250, 165);
                grafico.DrawString(f.Cliente.InscMunicipal, new XFont("Consolas", 12, XFontStyle.Regular), corFonte, 380, 165);

                //Valor por extenso
                grafico.DrawString(Constante.CAMPO_VALOR_EXTENSO, new XFont("Consolas", 12, XFontStyle.Bold), corFonte, alinhamento, 190);
                grafico.DrawString(DecimalToExtenso(f.ValorTotal), new XFont("Consolas", 12, XFontStyle.Regular), corFonte, pagina.Width / 2, 210, XStringFormats.Center);

                //Devem a
                formatacao.DrawString(string.Format("Devem a, {0} ou a sua ordem na praca e vencimento a cima indicado a importancia a cima, correspondete a Prestacao de Servico a baixo descriminados.",
                                                    f.Emissor.Nome), new XFont("Consolas", 12), XBrushes.Black, new XRect(5, 250, pagina.Width - 5, pagina.Height));

                //Lista de itens, quantidade e valores
                grafico.DrawString("Item Descrição", new XFont("Consolas", 12, XFontStyle.Bold), corFonte, 100, 310, XStringFormats.Center);
                grafico.DrawString("Quant.", new XFont("Consolas", 12, XFontStyle.Bold), corFonte, 300, 310, XStringFormats.Center);
                grafico.DrawString("Vl.Unitário", new XFont("Consolas", 12, XFontStyle.Bold), corFonte, 400, 310, XStringFormats.Center);
                grafico.DrawString("Valor", new XFont("Consolas", 12, XFontStyle.Bold), corFonte, 530, 310, XStringFormats.Center);
                var linha = 325;
                foreach (var item in f.Itens)
                {
                    grafico.DrawString(item.Descricao, new XFont("Consolas", 12, XFontStyle.Regular), corFonte, 5, linha, XStringFormats.BaseLineLeft);
                    grafico.DrawString(item.Quantidade.ToString(), new XFont("Consolas", 12, XFontStyle.Regular), corFonte, 300, linha, XStringFormats.Center);
                    grafico.DrawString(item.Valor.ToString("C2"), new XFont("Consolas", 12, XFontStyle.Regular), corFonte, 400, linha, XStringFormats.Center);
                    grafico.DrawString((item.Quantidade * item.Valor).ToString("C2"), new XFont("Consolas", 12, XFontStyle.Regular), corFonte, 530, linha, XStringFormats.Center);
                    linha += 15;
                }

                //Periodo, prestacao e numero do empenho
                grafico.DrawString(Constante.CAMPO_PER_SERV, new XFont("Consolas", 10, XFontStyle.Bold), corFonte, alinhamento, 490);
                grafico.DrawString(f.TempoPrestacao, new XFont("Consolas", 10, XFontStyle.Regular), corFonte, 120, 490);

                grafico.DrawString(Constante.DADOS_BANCO, new XFont("Consolas", 10, XFontStyle.Bold), corFonte, alinhamento, 510);

                grafico.DrawString(Constante.CAMPO_DADOS_BANCO_BC, new XFont("Consolas", 10, XFontStyle.Bold), corFonte, alinhamento, 520);
                grafico.DrawString(f.Emissor.NomeBanco, new XFont("Consolas", 10, XFontStyle.Regular), corFonte, 50, 520);

                grafico.DrawString(Constante.CAMPO_DADOS_BANCO_AG, new XFont("Consolas", 10, XFontStyle.Bold), corFonte, alinhamento, 530);
                grafico.DrawString(f.Emissor.Agencia, new XFont("Consolas", 10, XFontStyle.Regular), corFonte, 60, 530);

                grafico.DrawString(Constante.CAMPO_DADOS_BANCO_CC, new XFont("Consolas", 10, XFontStyle.Bold), corFonte, alinhamento, 540);
                grafico.DrawString(f.Emissor.Conta, new XFont("Consolas", 10, XFontStyle.Regular), corFonte, 95, 540);

                grafico.DrawString(Constante.CAMPO_EMPENHO, new XFont("Consolas", 10, XFontStyle.Bold), corFonte, alinhamento, 555);
                grafico.DrawString(f.Empenho, new XFont("Consolas", 10, XFontStyle.Regular), corFonte, 95, 555);

                grafico.DrawString(Constante.CAMPO_OBS, new XFont("Consolas", 10, XFontStyle.Bold), corFonte, 195, 490);
                formatacao.DrawString(f.Observacao, new XFont("Consolas", 12), XBrushes.Black, new XRect(195, 500, pagina.Width - 200, pagina.Height));

                //Legislacao e valor
                grafico.DrawString(Constante.LEGIS_1, new XFont("Consolas", 15, XFontStyle.Bold), corFonte, 210, 580, XStringFormats.Center);
                formatacao.DrawString(Constante.LEGIS_2, new XFont("Consolas", 12, XFontStyle.BoldItalic), XBrushes.Black, new XRect(alinhamento, 600, pagina.Width * (0.8), pagina.Height));

                grafico.DrawString(Constante.CAMPO_VALOR, new XFont("Consolas", 15, XFontStyle.Bold), corFonte, 530, 580, XStringFormats.Center);
                grafico.DrawString(f.ValorTotal.ToString("C2"), new XFont("Consolas", 12, XFontStyle.Bold), corFonte, 530, 600, XStringFormats.Center);

                //Protocolo de recebimento
                formatacao.DrawString(string.Format("Recebi(emos) da {0} os serviços constantes nesta Nota Fiscal de Serviços - FATURA - Serie ÚNICA Nº {1}",
                                                    f.Emissor.Nome, f.Numero), new XFont("Consolas", 15), XBrushes.Black, new XRect(5, 710, pagina.Width - 5, pagina.Height));
                grafico.DrawString("Data: _____/_____/__________", new XFont("Consolas", 15, XFontStyle.Regular), corFonte, pagina.Width / 2, 770, XStringFormats.Center);
                grafico.DrawString("Assinatura: __________________________________________", new XFont("Consolas", 15, XFontStyle.Regular), corFonte, pagina.Width / 2, 810, XStringFormats.Center);
                #endregion

                #region Separadores
                var cor = XPens.Black;
                //Dados da Empresa
                var       posicao = 0;
                const int espaco  = 2;
                var       tamanho = 100;
                grafico.DrawRoundedRectangle(cor, 0, posicao, pagina.Width * (0.6), tamanho, 5, 5);

                //Dados da Fatura
                grafico.DrawRoundedRectangle(cor, pagina.Width * (0.6), posicao, pagina.Width * (0.4), 100, 5, 5);

                //Dados do cliente
                posicao += tamanho + espaco;
                tamanho  = 70;
                grafico.DrawRoundedRectangle(cor, 0, posicao, pagina.Width, tamanho, 5, 5);

                //Valor por extenso
                posicao += tamanho + espaco;
                tamanho  = 60;
                grafico.DrawRoundedRectangle(cor, 0, posicao, pagina.Width, tamanho, 5, 5);

                //Descricao da divida
                posicao += tamanho + espaco;
                tamanho  = 60;
                grafico.DrawRoundedRectangle(cor, 0, posicao, pagina.Width, tamanho, 5, 5);

                //Lista de itens, quantidade e valores
                posicao += tamanho + espaco;
                tamanho  = 180;
                grafico.DrawRoundedRectangle(cor, 0, posicao, pagina.Width, tamanho, 5, 5);

                //Periodo, prestacao e numero do empenho
                posicao += tamanho + espaco;
                tamanho  = 80;
                grafico.DrawRoundedRectangle(cor, 0, posicao, pagina.Width * (0.30), tamanho, 5, 5);
                grafico.DrawRoundedRectangle(cor, pagina.Width * (0.30), posicao, pagina.Width * (0.70), tamanho, 5, 5);

                //Legislacao e valor
                posicao += tamanho + espaco;
                tamanho  = 80;
                grafico.DrawRoundedRectangle(cor, 0, posicao, pagina.Width * (0.8), tamanho, 5, 5);
                grafico.DrawRoundedRectangle(cor, pagina.Width * (0.8), posicao, pagina.Width * (0.2), tamanho, 5, 5);

                //Divisoria
                posicao += tamanho + 30;
                tamanho  = 1;
                grafico.DrawRoundedRectangle(cor, 0, posicao, pagina.Width, tamanho, 5, 5);

                //Protocolo de recibo
                posicao += tamanho + 30;
                tamanho  = 140;
                grafico.DrawRoundedRectangle(cor, 0, posicao, pagina.Width, tamanho, 5, 5);
                #endregion

                doc.Save(stream, true);

                return(stream);
            }
        }
        private void btnFinalizar_Click(object sender, EventArgs e)
        {
            using (var doc = new PdfSharp.Pdf.PdfDocument())
            {
                var page     = doc.AddPage();
                var graphics = PdfSharp.Drawing.XGraphics.FromPdfPage(page);

                var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                var textOSTitle   = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                var txtTitles     = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                var txtSubTitles  = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                var txtSubTitles2 = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);

                var font          = new PdfSharp.Drawing.XFont("Arial", 25);
                var fontTitle     = new PdfSharp.Drawing.XFont("Coolvetica", 12);
                var fontSubTitle  = new PdfSharp.Drawing.XFont("Coolvetica", 10);
                var fontSubTitle2 = new PdfSharp.Drawing.XFont("Coolvetica", 13);
                var fontTxts      = new PdfSharp.Drawing.XFont("Arial", 20);

                //Logo ZL
                graphics.DrawImage(PdfSharp.Drawing.XImage.FromFile(@"C:\Users\gabri\OneDrive\Documentos\Visual Studio 2019\ZL-Project\ZLProjectV13\ZLProject\ZLProject\img\zlBalacasLOGO.png"), 175, 10, 50, 70);

                //Primerio Título
                textOSTitle.DrawString("Ordem de Serviço - OS", fontTitle, PdfSharp.Drawing.XBrushes.LightGray, new PdfSharp.Drawing.XRect(400, 10, page.Width, page.Height));
                textOSTitle.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;

                //Cabeçalho
                textFormatter.DrawString("Z.L. Balanças ME", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(235, 43, page.Width, page.Height));
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;

                //Sub-Títulos
                txtSubTitles2.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                txtSubTitles2.DrawString("Assistência Técnica de Balanças e Máquinas", fontSubTitle2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 85, page.Width - 60, page.Height - 60));

                //Sub-Títulos
                txtSubTitles.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                txtSubTitles.DrawString("Manutenção de Balanças Mecânicas, Eletrônicas, Comerciais e Industriais", fontSubTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 102, page.Width - 60, page.Height - 60));

                //Sub-Títulos
                txtSubTitles.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                txtSubTitles.DrawString("Vendas e Automação Comercial        Cel: (11) 99388-7206", fontSubTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 117, page.Width - 60, page.Height - 60));

                //Sub-Títulos
                txtSubTitles.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                txtSubTitles.DrawString("CNPJ: 07.048.933 / 0001 - 06    IE: 336.737.460.116", fontSubTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 133, page.Width - 60, page.Height - 60));

                //Linha de divisão
                //graphics.DrawLine(PdfSharp.Drawing.XPens.Black, 100, 100, 100, 100);

                //Graphics gs = this.CreateGraphics();
                //Brush brush = new SolidBrush(Color.Black);
                //Pen pen = new Pen(brush);
                //gs.DrawLine(pen, new Point(200, 100), new Point(200, 100));


                //TXts Nome
                textOSTitle.DrawString("Nome:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-240, 170, page.Width, page.Height));
                txtTitles.DrawString(cmbCarregarClientes.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(85, 170, page.Width, page.Height));

                //TXts Endereço
                textOSTitle.DrawString("Endereço:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-230, 190, page.Width, page.Height));
                txtTitles.DrawString(txtEnderecoOS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(100, 190, page.Width, page.Height));

                //TXts Estado
                textOSTitle.DrawString("Estado:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(100, 190, page.Width, page.Height));
                txtTitles.DrawString(txtEstadoOS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(430, 190, page.Width, page.Height));

                //TXts Bairro
                textOSTitle.DrawString("Bairro:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-240, 210, page.Width, page.Height));
                txtTitles.DrawString(txtBairroOS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(85, 210, page.Width, page.Height));

                //TXts CNPJ
                textOSTitle.DrawString("CNPJ:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(94.5, 210, page.Width, page.Height));
                txtTitles.DrawString(txtCNPJOS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(415, 210, page.Width, page.Height));

                //TXts Município
                textOSTitle.DrawString("Município:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-230, 230, page.Width, page.Height));
                txtTitles.DrawString(txtMunicipioOS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(100, 230, page.Width, page.Height));

                //TXts CEP
                textOSTitle.DrawString("CEP:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(94.1, 230, page.Width, page.Height));
                txtTitles.DrawString(txtCEPOS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(415, 230, page.Width, page.Height));

                //TXts Data
                textOSTitle.DrawString("IE:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(95, 270, page.Width, page.Height));
                txtTitles.DrawString(txtIEOS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(415, 270, page.Width, page.Height));

                //TXts Email 1
                textOSTitle.DrawString("Email:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-240, 250, page.Width, page.Height));
                txtTitles.DrawString(txtEmailOS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(85, 250, page.Width, page.Height));

                //TXts Email 2
                textOSTitle.DrawString("/", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(13, 250, page.Width, page.Height));
                txtTitles.DrawString(txtEmail_2OS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(330, 250, page.Width, page.Height));


                //TXts Telefone
                textOSTitle.DrawString("Celular:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-235, 290, page.Width, page.Height));
                txtTitles.DrawString(txtTelefoneOS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(95, 290, page.Width, page.Height));

                //TXts IE
                textOSTitle.DrawString("Telefone:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-230, 270, page.Width, page.Height));
                txtTitles.DrawString(txtTelefone2OS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(100, 270, page.Width, page.Height));

                //TXts Celular
                textOSTitle.DrawString("Data:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(102, 290, page.Width, page.Height));
                txtTitles.DrawString(txtDataOS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(420, 290, page.Width, page.Height));

                //E-mail para contato
                //textOSTitle.DrawString("Forma de Pagamento:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-195, 309, page.Width, page.Height));
                //txtTitles.DrawString(txtFormaPag.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(170, 309, page.Width, page.Height));

                //Titulo Ocorrências
                textFormatter.DrawString("Ocorrências:", fontSubTitle2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-215, 350, page.Width, page.Height));

                //TXTs Ocorrências
                txtTitles.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Justify;
                txtTitles.DrawString(txtOcorrenciaOS.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(35, 370, page.Width - 90, page.Height - 90));
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(30, 370, 520, 110)); //MAX 120

                //TXTs Produtos
                textFormatter.DrawString("Qtd", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-255, 500, page.Width, page.Height));
                textFormatter.DrawString("Descrição", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-200, 500, page.Width, page.Height));
                textFormatter.DrawString("Unitário R$", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(105, 500, page.Width, page.Height));
                textFormatter.DrawString("Valor Total R$", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(213, 500, page.Width, page.Height));

                //Retangulos dos produtos - 1º linha
                //Quantidade
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(33, 520, 33, 18));

                //Descrição
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(67, 520, 300, 18));

                //Unitário R$
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(367, 520, 105, 18));

                //Valor total R$
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(472, 520, 80, 18));

                /*------------------------------------------------------------------------------------------------------------------------------------------*/

                /*//Retangulos dos produtos - 2º linha
                 * //Quantidade
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(33, 538, 33, 18));
                 *
                 * //Descrição
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(67, 538, 155, 18));
                 *
                 * //Unitário R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(367, 538, 105, 18));
                 *
                 * //Valor total R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(472, 538, 80, 18));
                 *
                 * /*------------------------------------------------------------------------------------------------------------------------------------------*/

                /*//Retangulos dos produtos - 3º linha
                 * //Quantidade
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(33, 556, 33, 18));
                 *
                 * //Descrição
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(67, 556, 155, 18));
                 *
                 * //Unitário R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(367, 556, 105, 18));
                 *
                 * //Valor total R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(472, 556, 80, 18));
                 *
                 *
                 * /*------------------------------------------------------------------------------------------------------------------------------------------*/

                /*//Retangulos dos produtos - 4º linha
                 * //Quantidade
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(33, 574, 33, 18));
                 *
                 * //Descrição
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(67, 574, 155, 18));
                 *
                 * //Unitário R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(367, 574, 105, 18));
                 *
                 * //Valor total R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(472, 574, 80, 18));
                 *
                 * /*------------------------------------------------------------------------------------------------------------------------------------------*/

                /*//Retangulos dos produtos - 5º linha
                 * //Quantidade
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(33, 592, 33, 18));
                 *
                 * //Descrição
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(67, 592, 155, 18));
                 *
                 * //Unitário R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(367, 592, 105, 18));
                 *
                 * //Valor total R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(472, 592, 80, 18));
                 *
                 * /*------------------------------------------------------------------------------------------------------------------------------------------*/

                /*//Retangulos dos produtos - 6º linha
                 * //Quantidade
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(33, 610, 33, 18));
                 *
                 * //Descrição
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(67, 610, 155, 18));
                 *
                 * //Unitário R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(367, 610, 105, 18));
                 *
                 * //Valor total R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(472, 610, 80, 18));
                 *
                 * /*------------------------------------------------------------------------------------------------------------------------------------------*/

                /*//Retangulos dos produtos - 7º linha
                 * //Quantidade
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(33, 628, 33, 18));
                 *
                 * //Descrição
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(67, 628, 155, 18));
                 *
                 * //Unitário R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(367, 628, 105, 18));
                 *
                 * //Valor total R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(472, 628, 80, 18));
                 *
                 * /*------------------------------------------------------------------------------------------------------------------------------------------*/

                /*//Retangulos dos produtos - 8º linha
                 * //Quantidade
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(33, 646, 33, 18));
                 *
                 * //Descrição
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(67, 646, 155, 18));
                 *
                 * //Unitário R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(367, 646, 105, 18));
                 *
                 * //Valor total R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(472, 646, 80, 18));
                 *
                 * /*------------------------------------------------------------------------------------------------------------------------------------------*/

                /* //Retangulos dos produtos - 9º linha
                 * //Quantidade
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(33, 664.10, 33, 18));
                 *
                 * //Descrição
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(67, 664.10, 155, 18));
                 *
                 * //Unitário R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(367, 664.10, 105, 18));
                 *
                 * //Valor total R$
                 * graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(472, 664.10, 80, 18));
                 *
                 * /*------------------------------------------------------------------------------------------------------------------------------------------*/

                //Retangulos dos produtos - 10º linha
                //Quantidade
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(33, 682, 33, 18));

                //Descrição
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(67, 682, 155, 18));
                textFormatter.DrawString("M/O Conserto:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-155, 685, page.Width - 60, page.Height - 60));


                //Equipamento
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(223, 682, 145, 18));

                //Unitário R$
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(367, 682, 105, 18));

                //Valor total R$
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(472, 682, 80, 18));

                /*------------------------------------------------------------------------------------------------------------------------------------------*/

                //Retangulos dos produtos - 11º linha
                //Garantia do Conserto
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(33, 711.3, 334, 18));
                textFormatter.DrawString("Garantia do Conserto: 90 dias", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-150, 712, page.Width - 60, page.Height - 60));

                //Unitário R$
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(367, 711.3, 105, 18));
                textFormatter.DrawString("Total Nota:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(135, 712, page.Width - 60, page.Height - 60));


                //Valor total R$
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(472, 711.3, 80, 18));

                /*------------------------------------------------------------------------------------------------------------------------------------------*/

                //Retangulos dos produtos - 12  º linha
                //Quantidade
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(33, 730, 519, 18));
                textFormatter.DrawString("Forma de Pgto.:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-185, 732, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(txtFormaPag.Text, fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-90, 733, page.Width - 60, page.Height - 60));

                /*------------------------------------------------------------------------------------------------------------------------------------------*/

                //Técnico
                textFormatter.DrawString("Técnico:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(-180, 790, page.Width - 60, page.Height - 60));
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(115, 800, 150, 1));

                //Cliente
                textFormatter.DrawString("Cliente:", fontTitle, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(90, 790, page.Width - 60, page.Height - 60));
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(385, 800, 150, 1));

                //Final OS - Endereço Z.  L. Balanças
                textFormatter.DrawString("Rua Sombrio, 45 - Vila Isabel - Guarulhos/SP - CEP: 07241-380", fontTitle, PdfSharp.Drawing.XBrushes.DarkGray, new PdfSharp.Drawing.XRect(30, 818, page.Width - 60, page.Height - 60));

                //Retangulos - Caixas onde estão as TXTs
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(30, 168, 520, 18));
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(30, 188, 520, 18));
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(30, 208, 520, 18));
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(30, 228, 520, 18));
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(30, 248, 520, 18));
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(30, 268, 520, 18));
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(30, 288, 520, 18));
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.DarkGray, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(30, 816, 520, 18));
                graphics.DrawRectangle(PdfSharp.Drawing.XPens.Black, PdfSharp.Drawing.XBrushes.Transparent, new PdfSharp.Drawing.XRect(30, 308, 520, 18));


                doc.Save("arquivo.pdf");
                System.Diagnostics.Process.Start("arquivo.pdf");
            }
        }
示例#22
0
        protected void GerarPDF_Click(object sender, EventArgs e)
        {
            vendacliente vendaCliente = new vendacliente();

            vendaCliente.VendaIdCliente = Convert.ToInt32(ddlNome.SelectedValue);
            vendaCliente.VendaIdViagem  = Convert.ToInt32(ddlViagem.SelectedValue);

            var vendaEncontrada = SvcVendaCliente.Pesquisa(vendaCliente);

            var document      = new PdfDocument();
            var page          = document.AddPage();
            var graphics      = XGraphics.FromPdfPage(page);
            var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
            var font          = new XFont("Calibri", 12);
            var fontColuna    = new XFont("Calibri", 14);

            int y = 55;

            textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
            textFormatter.DrawString("Destino: " + ddlViagem.SelectedItem.ToString(), font, XBrushes.Black, new XRect(30, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Cliente: " + ddlNome.SelectedItem.ToString(), font, XBrushes.Black, new XRect(200, y, page.Width - 60, page.Height - 60));
            y = y + 40;
            textFormatter.DrawString("Cliente", fontColuna, XBrushes.Black, new XRect(30, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Faixa Etaria", fontColuna, XBrushes.Black, new XRect(200, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Assento", fontColuna, XBrushes.Black, new XRect(300, y, page.Width - 60, page.Height - 60));
            textFormatter.DrawString("Valor Pago", fontColuna, XBrushes.Black, new XRect(370, y, page.Width - 60, page.Height - 60));
            y = y + 5;
            decimal ValorTotal      = 0;
            XRect   layoutRectangle = new XRect(0 /*X*/, page.Height - font.Height /*Y*/, page.Width /*Width*/, font.Height /*Height*/);
            XBrush  brush           = XBrushes.Black;
            string  noPages;
            int     i = 0;

            foreach (var item in vendaEncontrada)
            {
                if (y >= 760)
                {
                    page          = document.AddPage();
                    graphics      = XGraphics.FromPdfPage(page);
                    textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                    y             = 45;
                }
                ValorTotal += item.VendaValorPago;
                y           = y + 30;
                textFormatter.DrawString(SvcCliente.BuscarCliente(item.VendaIdCliente).Nome, font, XBrushes.Black, new XRect(30, y, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(item.FaixaEtaria, font, XBrushes.Black, new XRect(200, y, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(item.Assento.ToString(), font, XBrushes.Black, new XRect(300, y, page.Width - 60, page.Height - 60));
                textFormatter.DrawString(item.VendaValorPago.ToString(), font, XBrushes.Black, new XRect(370, y, page.Width - 60, page.Height - 60));
            }
            textFormatter.DrawString("Valor Total: " + ValorTotal.ToString(), font, XBrushes.Black, new XRect(100, 50 + y, page.Width - 60, page.Height - 60));
            document.Save("Vendas.pdf");

            PdfDocument pdfDocument = PdfReader.Open("Vendas.pdf", PdfDocumentOpenMode.Modify);

            noPages = pdfDocument.Pages.Count.ToString();
            for (i = 0; i < pdfDocument.Pages.Count; ++i)
            {
                PdfPage page1 = pdfDocument.Pages[i];
                using (XGraphics gfx = XGraphics.FromPdfPage(page1))
                {
                    gfx.DrawString(
                        "Page " + (i + 1).ToString() + " of " + noPages,
                        font,
                        brush,
                        layoutRectangle,
                        XStringFormats.Center);

                    gfx.DrawString(
                        "Data: " + DateTime.Now,
                        font,
                        brush,
                        layoutRectangle,
                        XStringFormats.TopLeft);
                }
            }
            pdfDocument.Save("Vendas.pdf");
            System.Diagnostics.Process.Start("chrome.exe", "Vendas.pdf");
        }
示例#23
0
        public void GerarPdf()
        {
            var fileName   = @"C:\Users\810235\Documents\TestePDF.pdf";
            int inicio     = 30;
            int linha      = 68;
            int pularLinha = 13;

            try
            {
                var consulta = ConsultaNr();

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

                double val    = 0;
                double espaco = 25;

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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


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

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

                val    = 0;
                espaco = 25;

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

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

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

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

                val += graphics.MeasureString("Natureza de Despesa", new XFont("Calibri", 10, XFontStyle.Bold)).Width + espaco;
                textFormatter.DrawString("UGR", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + val, linha, page.Width - 60, page.Height - 60));

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

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


                val = 0;

                linha += (pularLinha);
                textFormatter.DrawString(consulta.Uo.ToString(), new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));

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

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

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

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

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

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


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

                val = graphics.MeasureString("Cronograma", new XFont("Calibri", 10, XFontStyle.Bold)).Width * 2;
                graphics.DrawRectangle(XPens.Silver, XBrushes.White, new XRect(inicio + 217, linha + 11.8, val, 0.1));


                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                linha += (pularLinha * 2);
                textFormatter.DrawString("Mês", new XFont("Calibri", 10, XFontStyle.Bold), XBrushes.Black, new XRect(inicio + 217, linha, page.Width - 60, page.Height - 60));

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

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

                int i = 0;
                foreach (var propertyInfo in properties)
                {
                    if (propertyInfo.Name.Contains("Mes"))
                    {
                        linha += (pularLinha);
                        textFormatter.DrawString(propertyInfo.GetValue(consulta).ToString(), new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + 217, linha, page.Width - 60, page.Height - 60));

                        i += 1;
                    }
                }

                linha -= (pularLinha * i);
                i      = 0;
                foreach (var propertyInfo in properties)
                {
                    if (propertyInfo.Name.Contains("Valor") && propertyInfo.Name != "Valor")
                    {
                        linha += (pularLinha);
                        textFormatter.DrawString(propertyInfo.GetValue(consulta).ToString(), new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio + 217 + val, linha, page.Width - 60, page.Height - 60));
                        i += 1;
                    }
                }

                var text = "";

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

                linha += (pularLinha);
                textFormatter.DrawString(consulta.Observacao1, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));
                linha += (pularLinha);
                textFormatter.DrawString(consulta.Observacao2, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));
                linha += (pularLinha);
                textFormatter.DrawString(consulta.Observacao3, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));
                linha += (pularLinha);

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

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


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

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


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

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


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

                linha += (pularLinha * 9);
                textFormatter.DrawString(text, new XFont("Calibri", 10, XFontStyle.Regular), XBrushes.Black, new XRect(inicio, linha, page.Width - 60, page.Height - 60));


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

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

                document.Save(fileName);
                System.Diagnostics.Process.Start(fileName);
            }
            catch
            {
                //handle exception
            }
        }
示例#24
0
        public void CriarPDFRecibo(string txtcliente, string txtEndereco, string txtimportancia, string txtreferente)
        {
            // C#
            using (var doc = new PdfSharp.Pdf.PdfDocument())
            {
                //var NomeCliente = nome;
                //var DadosCliente = new CLIENTEDAL().CONSULTATODOSPELONOME(NomeCliente);

                decimal valor = Convert.ToDecimal(txtimportancia);
                var     TextoValorExtersom = EscreverExtenso(valor);

                var page          = doc.AddPage();
                var graphics      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                var font          = new PdfSharp.Drawing.XFont("Arial", 14);
                var fontRecibo    = new PdfSharp.Drawing.XFont("Microsoft Sans Serif", 30);
                var fontTexto     = new PdfSharp.Drawing.XFont("Arial", 12, PdfSharp.Drawing.XFontStyle.Underline);

                // Imagem.
                var caminho = Server.MapPath("Pegasus.png");
                graphics.DrawImage(PdfSharp.Drawing.XImage.FromFile(caminho), 0, 30, 200, 100);


                // C#
                // Textos.
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                textFormatter.DrawString("RECIBO Aluguel", fontRecibo, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(60, 30, page.Width - 60, page.Height - 60));

                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                textFormatter.DrawString("Valor", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(60, 60, page.Width - 60, page.Height - 60));
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                textFormatter.DrawString(valor.ToString("C"), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(60, 80, page.Width - 60, page.Height - 60));

                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString("Recebi (emos) de: ", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 150, page.Width - 60, page.Height - 60));
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString(txtcliente.ToString(), fontTexto, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(150, 150, page.Width - 60, page.Height - 60));


                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString("Endereço: ", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 170, page.Width - 60, page.Height - 60));
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString(txtEndereco.ToString(), fontTexto, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(100, 170, page.Width - 60, page.Height - 60));

                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString("A importancia de: ", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 190, page.Width - 60, page.Height - 60));
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString(TextoValorExtersom.ToString(), fontTexto, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(150, 190, page.Width - 60, page.Height - 60));

                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString("Referente: ", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 210, page.Width - 60, page.Height - 60));
                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                textFormatter.DrawString(txtreferente.ToString(), fontTexto, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(100, 210, page.Width - 60, page.Height - 60));

                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                textFormatter.DrawString("Por ser verdade, firmo o presente.", font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 300, page.Width - 60, page.Height - 60));

                //desmenbrando a data
                CultureInfo        culture = new CultureInfo("pt-BR");
                DateTimeFormatInfo dtfi    = culture.DateTimeFormat;

                int    dia        = DateTime.Now.Day;
                int    ano        = DateTime.Now.Year;
                string mes        = culture.TextInfo.ToTitleCase(dtfi.GetMonthName(DateTime.Now.Month));
                string diasemana  = culture.TextInfo.ToTitleCase(dtfi.GetDayName(DateTime.Now.DayOfWeek));
                string DataRecibo = "Manaus, AM, " + dia + " de " + mes + " de " + ano;

                textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Right;
                textFormatter.DrawString(DataRecibo, font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(30, 320, page.Width - 60, page.Height - 60));

                string pdfPath = Server.MapPath(@"ReciboGErado.pdf");
                doc.Save(pdfPath);

                WebClient client = new WebClient();
                Byte[]    buffer = client.DownloadData(pdfPath);
                //Response.Clear();
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-length", buffer.Length.ToString());
                Response.BinaryWrite(buffer);
                Response.End();
            }
        }
示例#25
0
 /// <summary>Add a new page if the current page is not empty</summary>
 public void addPage() {
     if (!_isPageEmpty) {
         if (_pageCount != 0)
             addPagenumber();
         _page = new PdfSharp.Pdf.PdfPage();
         if (_pageCount == 0) {
             _size.Width = _page.Width;
             _size.Height = _page.Height;
             _area = new PdfSharp.Drawing.XRect {
                 X = PdfSharp.Drawing.XUnit.FromMillimeter(10),
                 Y = PdfSharp.Drawing.XUnit.FromMillimeter(10),
                 Width = _page.Width - PdfSharp.Drawing.XUnit.FromMillimeter(20),
                 Height = _page.Height - PdfSharp.Drawing.XUnit.FromMillimeter(45)
             };
         } else {
             _page = new PdfSharp.Pdf.PdfPage();
             _page.Width = _size.Width;
             _page.Height = _size.Height;
         }
         _horizontalePosition = _area.X;
         _verticalPosition = _area.Y;
         _doc.AddPage(_page);
         if (_graphics != null)
             _graphics.Dispose();
         _graphics = PdfSharp.Drawing.XGraphics.FromPdfPage(_page);
         _textformater = new PdfSharp.Drawing.Layout.XTextFormatter(_graphics);
         _pageCount++;
         _isPageEmpty = true;
     }
 }
示例#26
0
        public void relatorio(int id, int idFesta)
        {
            using (var doc = new PdfSharp.Pdf.PdfDocument())
            {
                BD_FESTA festa = new BD_FESTA();
                BD_ITENS itens = new BD_ITENS();

                String[] dados = new String[4];
                dados = festa.pegarDadosFesta(id, idFesta);

                var    page          = doc.AddPage();
                var    graphics      = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                var    textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);
                XBrush titulos       = new XSolidBrush(XColor.FromArgb(22, 93, 180));

                var font  = new PdfSharp.Drawing.XFont("Comic Sans MS", 20);
                var font2 = new PdfSharp.Drawing.XFont("Verdana", 12);

                graphics.DrawRoundedRectangle(PdfSharp.Drawing.XPens.Black, 10, 10, 576, 822, 10, 10);

                textFormatter.DrawString(dados[0], font, titulos, new PdfSharp.Drawing.XRect(40, 50, page.Width, page.Height));
                graphics.DrawImage(PdfSharp.Drawing.XImage.FromFile(@"C:\Users\erick\Desktop\Projeto Interdisciplinar 2º Semestre\LAFIESTA\METODIKU\Resources\tiozao.png"), 530, 30, 50, 50);

                textFormatter.DrawString("Local da festa: ", font2, titulos, new PdfSharp.Drawing.XRect(40, 100, 150, 70));
                textFormatter.DrawString(dados[1], font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(132, 100, 150, 70));
                textFormatter.DrawString("Total de convidados: ", font2, titulos, new PdfSharp.Drawing.XRect(350, 100, 150, 70));
                textFormatter.DrawString(dados[2], font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(480, 100, 150, 70));

                textFormatter.DrawString("Data da festa: ", font2, titulos, new PdfSharp.Drawing.XRect(40, 120, 150, 70));
                textFormatter.DrawString(dados[3], font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(132, 120, 250, 70));

                textFormatter.DrawString("Comidas: ", font2, titulos, new PdfSharp.Drawing.XRect(40, 160, 150, 70));

                textFormatter.DrawString("Número", font2, titulos, new PdfSharp.Drawing.XRect(60, 180, 30, 70));
                textFormatter.DrawString("Tipo", font2, titulos, new PdfSharp.Drawing.XRect(170, 180, 100, 70));
                textFormatter.DrawString("Nome", font2, titulos, new PdfSharp.Drawing.XRect(310, 180, 100, 70));
                textFormatter.DrawString("Unidade", font2, titulos, new PdfSharp.Drawing.XRect(470, 180, 100, 70));

                DataTable comidas = new DataTable();
                comidas = itens.comidas(idFesta);
                int    y    = 205;
                string item = null;
                if (comidas != null)
                {
                    for (int i = 0; i < comidas.Rows.Count; i++)
                    {
                        DataRow dr = comidas.Rows[i];
                        textFormatter.DrawString(dr[0].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(80, y, 550, 70));
                        textFormatter.DrawString(dr[1].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(140, y, 550, 70));
                        textFormatter.DrawString(dr[2].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(270, y, 550, 70));
                        textFormatter.DrawString(dr[3].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(480, y, 550, 70));
                        y += 20;
                    }
                }

                textFormatter.DrawString("Bebidas: ", font2, titulos, new PdfSharp.Drawing.XRect(40, y + 20, 150, 70));
                y += 40;

                textFormatter.DrawString("Número", font2, titulos, new PdfSharp.Drawing.XRect(60, y, 30, 70));
                textFormatter.DrawString("Tipo", font2, titulos, new PdfSharp.Drawing.XRect(150, y, 100, 70));
                textFormatter.DrawString("Nome", font2, titulos, new PdfSharp.Drawing.XRect(290, y, 100, 70));
                textFormatter.DrawString("Unidade", font2, titulos, new PdfSharp.Drawing.XRect(470, y, 100, 70));

                DataTable bebidas = new DataTable();
                bebidas = itens.bebidas(idFesta);
                if (bebidas != null)
                {
                    y += 30;
                    for (int i = 0; i < bebidas.Rows.Count; i++)
                    {
                        DataRow dr = bebidas.Rows[i];
                        textFormatter.DrawString(dr[0].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(80, y, 550, 70));
                        textFormatter.DrawString(dr[1].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(140, y, 550, 70));
                        textFormatter.DrawString(dr[2].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(270, y, 550, 70));
                        textFormatter.DrawString(dr[3].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(480, y, 550, 70));
                        y += 20;
                    }
                }

                textFormatter.DrawString("Utensilios: ", font2, titulos, new PdfSharp.Drawing.XRect(40, y + 20, 150, 70));
                y += 40;

                textFormatter.DrawString("Número", font2, titulos, new PdfSharp.Drawing.XRect(60, y, 30, 70));
                textFormatter.DrawString("Tipo", font2, titulos, new PdfSharp.Drawing.XRect(150, y, 100, 70));
                textFormatter.DrawString("Nome", font2, titulos, new PdfSharp.Drawing.XRect(290, y, 100, 70));
                textFormatter.DrawString("Unidade", font2, titulos, new PdfSharp.Drawing.XRect(470, y, 100, 70));

                DataTable utensilios = new DataTable();
                utensilios = itens.utensilios(idFesta);
                if (utensilios != null)
                {
                    y += 30;
                    for (int i = 0; i < utensilios.Rows.Count; i++)
                    {
                        DataRow dr = utensilios.Rows[i];
                        textFormatter.DrawString(dr[0].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(80, y, 550, 70));
                        textFormatter.DrawString(dr[1].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(140, y, 550, 70));
                        textFormatter.DrawString(dr[2].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(270, y, 550, 70));
                        textFormatter.DrawString(dr[3].ToString(), font2, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(480, y, 550, 70));
                        y += 20;
                    }
                }

                doc.Save(dados[0] + ".pdf");
                System.Diagnostics.Process.Start(dados[0] + ".pdf");
            }
        }
示例#27
0
        public string GerarPDF(EmitiCertificado certificado)
        {
            var codigo = Db.ParticipanteEvento.FirstOrDefault
                             (x => x.ParticipanteId == certificado.UsuarioId && x.EventoId == certificado.EventoId && x.ConfirmacaoPresenca == true);

            var usuario = Db.Usuario.Find(certificado.UsuarioId);

            var participante = Db.Participante.Find(usuario.Id);

            var evento = Db.Evento.Find(certificado.EventoId);

            var agenda = Db.AgendaEvento.Find(evento.AgendaEventoId);

            if (usuario == null)
            {
                return("Usuario não encontrado.");
            }
            if (evento == null)
            {
                return("Evento não encontrado.");
            }
            if (agenda == null)
            {
                return("Agenda não encontrada.");
            }


            //gera certificado
            var doc = new PdfDocument();

            var page = doc.AddPage();

            page.Height = XUnit.FromInch(5.5);

            var graphics = XGraphics.FromPdfPage(page);

            var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(graphics);

            var fontCertificado = new XFont("Arial", 30, XFontStyle.Bold);


            graphics.DrawImage(XImage.FromFile(@"C:\Users\Markim\Documents\KonohaAPI\KonohaApi\bg.png")
                               , 0, 0, page.Width + 60, page.Height);


            textFormatter.DrawString("Certificado Konoha ", fontCertificado, XBrushes.Black,
                                     new XRect(160, 110, page.Width, page.Height));

            textFormatter.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Justify;
            textFormatter.DrawString($"Certificamos para os devidos fins que {usuario.Nome}, CPF n.º {usuario.Cpf} participou do (a) {evento.TipoEvento} " +
                                     $"'{evento.Nome}' ministrado(a) pelo(a) {evento.Apresentador}, durante a {agenda.Nome}, no período de {agenda.DataInicio.Day} a " +
                                     $"{agenda.DateEncerramento.Day} de {agenda.DataInicio.ToString("MMMM")} de {agenda.DataInicio.Year} com carga horária de {evento.CargaHoraria} horas."
                                     , new XFont("Arial", 14, XFontStyle.Regular)
                                     , XBrushes.Black, new XRect(30, 180, page.Width - 60, page.Height - 60));

            textFormatter.DrawString("Código de validação:", new XFont("Arial", 10, XFontStyle.Bold), XBrushes.Black, new XRect(397, 370, page.Width - 60, page.Height - 60));
            textFormatter.DrawString(codigo.CodigoValidacao, new XFont("Arial", 10, XFontStyle.Regular), XBrushes.Black, new XRect(500, 370, page.Width - 60, page.Height - 60));
            string caminho = @"C:\Users\Markim\Documents\KonohaAPI\KonohaApi\Certificados\Certificado" + codigo.CodigoValidacao + ".pdf";

            doc.Save(caminho);

            return(caminho);
        }
示例#28
0
        }       //	translate

        public override void PaintPdf(XGraphics g2D, int pageNo, PointF pageStart, Ctx ctx, bool isView)
        {
            m_solidbrush = new SolidBrush(Color.Black);
            PointF location = GetAbsoluteLocation(pageStart);

            //
            if (m_originalString != null)
            {
                Translate(ctx);
            }

            AttributedString            aString = null;
            AttributedCharacterIterator iter    = null;
            //	AttributedCharacterIterator iter2 = null;
            float xPos   = (float)location.X;
            float yPos   = (float)location.Y;
            float yPen   = 0f;
            float height = 0f;
            float width  = 0f;

            //	for all lines
            for (int i = 0; i < m_string_paper.Length; i++)
            {
                //	Get Text
                if (isView)
                {
                    if (m_string_view[i] == null)
                    {
                        continue;
                    }
                    aString = m_string_view[i];
                }
                else
                {
                    if (m_string_paper[i] == null)
                    {
                        continue;
                    }
                    aString = m_string_paper[i];
                }
                iter = aString.GetIterator();
                //	Zero Length
                if (iter.GetBeginIndex() == iter.GetEndIndex())
                {
                    continue;
                }


                //	Check for Tab (just first) and 16 bit characters
                int  tabPos = -1;
                bool is8Bit = true;
                for (char c = iter.First(); c != DONE; c = iter.Next())
                {
                    if (c == '\t' && tabPos == -1)
                    {
                        tabPos = iter.GetIndex();
                    }
                    if (c > 255)
                    {
                        is8Bit = false;
                    }
                }

                TextLayout layout = null;
                float      xPen   = xPos;

                //	No Limit
                if (p_maxWidth == 0f)
                {
                    if (tabPos == -1)
                    {
                        layout = new TextLayout(iter);
                        yPen   = yPos + layout.GetAscent();
                        //	layout.draw(g2D, xPen, yPen);
                        //m_font);
                        //g2D.setPaint(m_paint);
                        //XFont d = new XFont(m_font, new XPdfFontOptions(PdfSharp.Pdf.PdfFontEncoding.Unicode, PdfSharp.Pdf.PdfFontEmbedding.Automatic));

                        //StringBuilder txt = new StringBuilder();
                        //txt.Append("\u202D")
                        //.Append(iter.GetText())
                        //.Append("\u202C");
                        //g2D.DrawString(

                        XPdfFontOptions options = new XPdfFontOptions(PdfSharp.Pdf.PdfFontEncoding.Unicode, PdfSharp.Pdf.PdfFontEmbedding.Always);

                        PdfSharp.Drawing.Layout.XTextFormatter tf = new PdfSharp.Drawing.Layout.XTextFormatter(g2D);

                        //XStringFormat sf = new XStringFormat();
                        //sf.Alignment = XStringAlignment.Near;

                        //tf.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;

                        //tf.DrawString(iter.GetText(), new XFont(m_font, options), new XSolidBrush(XColors.Black), (double)xPen, (double)yPen);
                        g2D.DrawString(iter.GetText(), new XFont(m_font, options), new XSolidBrush(XColors.Black), (double)xPen, (double)yPen, new XStringFormat()
                        {
                            Alignment = XStringAlignment.Near
                        });
                        //
                        yPos += layout.GetAscent() + layout.GetDescent() + layout.GetLeading();
                        if (width < layout.GetAdvance())
                        {
                            width = layout.GetAdvance();
                        }
                    }
                    else        //	we have a tab
                    {
                        LineBreakMeasurer measurer = new LineBreakMeasurer(iter);
                        layout = measurer.NextLayout(9999, tabPos);
                        float lineHeight_1 = layout.GetAscent() + layout.GetDescent() + layout.GetLeading();
                        yPen = yPos + layout.GetAscent();
                        g2D.DrawString(iter.GetText(), new XFont(m_font, new XPdfFontOptions(PdfSharp.Pdf.PdfFontEncoding.Unicode, PdfSharp.Pdf.PdfFontEmbedding.Always)), new XSolidBrush(XColors.Black), (double)xPen, (double)yPen);          //	first part before tab
                        xPen = GetTabPos(xPos, layout.GetAdvance());
                        float lineWidth = xPen - xPos;
                        layout = measurer.NextLayout(9999);//, iter.getEndIndex(), true);
                        float lineHeight_2 = layout.GetAscent() + layout.GetDescent() + layout.GetLeading();
                        //layout.draw(g2D, xPen, yPen);		//	second part after tab
                        //
                        yPos      += Math.Max(lineHeight_1, lineHeight_2);
                        lineWidth += layout.GetAdvance();
                        if (width < lineWidth)
                        {
                            width = lineWidth;
                        }
                    }
                    //	log.finest( "StringElement.paint - No Limit - " + location.x + "/" + yPos
                    //		+ " w=" + layout.getAdvance() + ",h=" + lineHeight + ", Bounds=" + layout.getBounds());
                }
                //	Size Limits
                else
                {
                    bool fastDraw = LayoutEngine.s_FASTDRAW;
                    if (fastDraw && !isView && !is8Bit)
                    {
                        fastDraw = false;
                    }
                    LineBreakMeasurer measurer = new LineBreakMeasurer(iter);
                    while (measurer.GetPosition() < iter.GetEndIndex())
                    {
                        if (tabPos == -1)
                        {
                            layout = measurer.NextLayout(p_maxWidth);
                            // use fastDraw if the string fits in one line
                            if (fastDraw && iter.GetEndIndex() != measurer.GetPosition())
                            {
                                fastDraw = false;
                            }
                        }
                        else    //	tab
                        {
                            fastDraw = false;
                            layout   = measurer.NextLayout(p_maxWidth, tabPos);
                        }
                        //	Line Height
                        float lineHeight = layout.GetAscent() + layout.GetDescent() + layout.GetLeading();
                        if (p_maxHeight == -1f && i == 0)               //	one line only
                        {
                            p_maxHeight = lineHeight;
                        }
                        //	If we have hight left over
                        if (p_maxHeight == 0f || (height + lineHeight) <= p_maxHeight)
                        {
                            yPen = (float)location.Y + height + layout.GetAscent();
                            //	Tab in Text
                            if (tabPos != -1)
                            {
                                layout.Draw(g2D, (double)xPen, (double)yPen);   //	first part before tab
                                xPen   = GetTabPos(xPos, layout.GetAdvance());
                                layout = measurer.NextLayout(p_width, iter.GetEndIndex());
                                tabPos = -1;    //	reset (just one tab)
                            }
                            else if ((X_AD_PrintFormatItem.FIELDALIGNMENTTYPE_TrailingRight.Equals(p_FieldAlignmentType) && layout.IsLeftToRight()) ||
                                     (X_AD_PrintFormatItem.FIELDALIGNMENTTYPE_LeadingLeft.Equals(p_FieldAlignmentType)) && !layout.IsLeftToRight())
                            {
                                xPen += p_maxWidth - layout.GetAdvance();
                            }
                            else if (X_AD_PrintFormatItem.FIELDALIGNMENTTYPE_Center.Equals(p_FieldAlignmentType))
                            {
                                xPen += (p_maxWidth - layout.GetAdvance()) / 2;
                            }
                            else if (X_AD_PrintFormatItem.FIELDALIGNMENTTYPE_Block.Equals(p_FieldAlignmentType) && measurer.GetPosition() < iter.GetEndIndex())
                            {
                                //layout = layout.getJustifiedLayout(p_maxWidth);
                                fastDraw = false;
                            }
                            if (fastDraw)
                            {
                                //g2D.setFont(m_font);
                                //g2D.setPaint(m_paint);
                                g2D.DrawString(iter.GetText(), new XFont(m_font, new XPdfFontOptions(PdfSharp.Pdf.PdfFontEncoding.Unicode, PdfSharp.Pdf.PdfFontEmbedding.Always)), new XSolidBrush(XColors.Black), (double)xPen, (double)yPen - 7);
                            }
                            else
                            {
                                layout.Draw(g2D, (double)xPen, (double)yPen);
                            }
                            height += lineHeight;
                            //	log.finest( "StringElement.paint - Limit - " + xPen + "/" + yPen
                            //		+ " w=" + layout.getAdvance() + ",h=" + lineHeight + ", Align=" + p_FieldAlignmentType + ", Max w=" + p_maxWidth + ",h=" + p_maxHeight + ", Bounds=" + layout.getBounds());
                        }
                    }
                    width = p_maxWidth;
                } //	size limits
            }     //	for all strings
            if (m_check != null)
            {
                int x = (int)(location.X + width + 1);
                int y = (int)(location.Y);
                //g2D.DrawImage((bool)m_check ? LayoutEngine.IMAGE_TRUE : LayoutEngine.IMAGE_FALSE, x, y);
            }
        }
示例#29
0
        private void btn_PDF_Click(object sender, EventArgs e)
        {
            try
            {
                if (opc == 1)
                {
                    using (var doc = new PdfSharp.Pdf.PdfDocument())
                    {
                        var page       = doc.AddPage();
                        var grafico    = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                        var text_forma = new PdfSharp.Drawing.Layout.XTextFormatter(grafico);
                        var fontT      = new PdfSharp.Drawing.XFont("Arial", 16);
                        var font       = new PdfSharp.Drawing.XFont("Arial", 13);

                        //Dados Pessoais
                        text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                        text_forma.DrawString(lbl_Nome.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 40, page.Width, page.Height));
                        text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                        text_forma.DrawString(lbl_nacionalidade.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 70, page.Width, page.Height));
                        text_forma.DrawString(lbl_Endereco.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 85, page.Width, page.Height));
                        text_forma.DrawString(lbl_Cidade.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 100, page.Width, page.Height));
                        text_forma.DrawString(lbl_Tel.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 115, page.Width, page.Height));
                        text_forma.DrawString(lbl_Email.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 130, page.Width, page.Height));

                        //Objetivo
                        text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                        text_forma.DrawString(lbl_Objetivo.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 180, page.Width, page.Height));
                        grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 200, 492, 4);
                        text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                        text_forma.DrawString(lbl_Area.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 220, page.Width, page.Height));
                        text_forma.DrawString(lbl_Cargo.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 235, page.Width, page.Height));

                        //Formação Acadêmica
                        text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                        text_forma.DrawString(lbl_formacao.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 285, page.Width, page.Height));
                        grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 305, 492, 4);
                        text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                        text_forma.DrawString(lbl_escolaridade.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 325, page.Width, page.Height));

                        if (aux1 != "" && aux2 != "" && aux3 != "" && aux4 != "")
                        {
                            //Atividades Extracurriculares
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                            text_forma.DrawString(lbl_Atividades.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 375, page.Width, page.Height));
                            grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 395, 492, 4);
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                            text_forma.DrawString(lbl_Curso1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 415, page.Width, page.Height));
                            text_forma.DrawString(lbl_Curso2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 430, page.Width, page.Height));
                            text_forma.DrawString(lbl_Idioma1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 445, page.Width, page.Height));
                            text_forma.DrawString(lbl_Idioma2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 460, page.Width, page.Height));
                        }
                        else if (aux1 != "" || aux2 != "" || aux3 != "" || aux4 != "")
                        {
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                            text_forma.DrawString(lbl_Atividades.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 375, page.Width, page.Height));
                            grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 395, 492, 4);
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                        }


                        if (aux1 != "")
                        {
                            text_forma.DrawString(lbl_Curso1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 415, page.Width, page.Height));
                        }

                        if (aux2 != "")
                        {
                            text_forma.DrawString(lbl_Curso2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 430, page.Width, page.Height));
                        }

                        if (aux3 != "")
                        {
                            text_forma.DrawString(lbl_Idioma1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 445, page.Width, page.Height));
                        }

                        if (aux4 != "")
                        {
                            text_forma.DrawString(lbl_Idioma2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 460, page.Width, page.Height));
                        }


                        if (aux5 != "" && aux6 != "")
                        {
                            //Experiência Profissional
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                            text_forma.DrawString(lbl_Exp.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 510, page.Width, page.Height));
                            grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 530, 492, 4);
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                            text_forma.DrawString(lbl_Empresa1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 550, page.Width, page.Height));
                            text_forma.DrawString(lbl_Tempo_Empresa1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 565, page.Width, page.Height));
                            text_forma.DrawString(lbl_Empresa2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 580, page.Width, page.Height));
                            text_forma.DrawString(lbl_Tempo_Empresa2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 595, page.Width, page.Height));
                            text_forma.DrawString(lbl_Descricao.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 680, 405, page.Height));
                        }
                        else if (aux5 != "" || aux6 != "")
                        {
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                            text_forma.DrawString(lbl_Exp.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 510, page.Width, page.Height));
                            grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 530, 492, 4);
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                        }
                        if (aux5 != "")
                        {
                            text_forma.DrawString(lbl_Empresa1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 550, page.Width, page.Height));
                            text_forma.DrawString(lbl_Tempo_Empresa1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 565, page.Width, page.Height));
                        }

                        if (aux6 != "")
                        {
                            text_forma.DrawString(lbl_Empresa2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 580, page.Width, page.Height));
                            text_forma.DrawString(lbl_Tempo_Empresa2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 595, page.Width, page.Height));
                        }

                        if (aux7 != "")
                        {
                            text_forma.DrawString(lbl_Descricao.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 680, 405, page.Height));
                        }
                        try
                        {
                            doc.Save("Currículo.pdf");
                            System.Diagnostics.Process.Start("Currículo.pdf");
                        }
                        catch
                        {
                            throw new Exception("Feche o pdf que já esta aberto!");
                        }
                    }
                }
                else if (opc == 2)
                {
                    using (var doc = new PdfSharp.Pdf.PdfDocument())
                    {
                        var page       = doc.AddPage();
                        var grafico    = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                        var text_forma = new PdfSharp.Drawing.Layout.XTextFormatter(grafico);
                        var fontT      = new PdfSharp.Drawing.XFont("Arial", 16);
                        var font       = new PdfSharp.Drawing.XFont("Arial", 13);

                        //Dados Pessoais
                        text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                        text_forma.DrawString(lbl_Nome.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 40, page.Width, page.Height));
                        text_forma.DrawString(lbl_nacionalidade.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 70, page.Width, page.Height));
                        text_forma.DrawString(lbl_Endereco.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 85, page.Width, page.Height));
                        text_forma.DrawString(lbl_Cidade.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 100, page.Width, page.Height));
                        text_forma.DrawString(lbl_Tel.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 115, page.Width, page.Height));
                        text_forma.DrawString(lbl_Email.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 130, page.Width, page.Height));

                        //Objetivo
                        text_forma.DrawString(lbl_Objetivo.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 180, page.Width, page.Height));
                        grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 200, 492, 4);
                        text_forma.DrawString(lbl_Area.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 220, page.Width, page.Height));
                        text_forma.DrawString(lbl_Cargo.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 235, page.Width, page.Height));

                        //Formação Acadêmica
                        text_forma.DrawString(lbl_formacao.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 285, page.Width, page.Height));
                        grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 305, 492, 4);
                        text_forma.DrawString(lbl_escolaridade.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 325, page.Width, page.Height));


                        if (aux1 != "" && aux2 != "" && aux3 != "" && aux4 != "")
                        {
                            //Atividades Extracurriculares
                            text_forma.DrawString(lbl_Atividades.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 375, page.Width, page.Height));
                            grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 395, 492, 4);
                            text_forma.DrawString(lbl_Curso1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 415, page.Width, page.Height));
                            text_forma.DrawString(lbl_Curso2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 430, page.Width, page.Height));
                            text_forma.DrawString(lbl_Idioma1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 445, page.Width, page.Height));
                            text_forma.DrawString(lbl_Idioma2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 460, page.Width, page.Height));
                        }
                        else if (aux1 != "" || aux2 != "" || aux3 != "" || aux4 != "")
                        {
                            text_forma.DrawString(lbl_Atividades.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 375, page.Width, page.Height));
                            grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 395, 492, 4);
                        }


                        if (aux1 != "")
                        {
                            text_forma.DrawString(lbl_Curso1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 415, page.Width, page.Height));
                        }

                        if (aux2 != "")
                        {
                            text_forma.DrawString(lbl_Curso2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 430, page.Width, page.Height));
                        }

                        if (aux3 != "")
                        {
                            text_forma.DrawString(lbl_Idioma1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 445, page.Width, page.Height));
                        }

                        if (aux4 != "")
                        {
                            text_forma.DrawString(lbl_Idioma2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 460, page.Width, page.Height));
                        }


                        if (aux5 != "" && aux6 != "")
                        {
                            //Experiência Profissional
                            text_forma.DrawString(lbl_Exp.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 510, page.Width, page.Height));
                            grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 530, 492, 4);
                            text_forma.DrawString(lbl_Empresa1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 550, page.Width, page.Height));
                            text_forma.DrawString(lbl_Tempo_Empresa1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 565, page.Width, page.Height));
                            text_forma.DrawString(lbl_Empresa2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 580, page.Width, page.Height));
                            text_forma.DrawString(lbl_Tempo_Empresa2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 595, page.Width, page.Height));
                            text_forma.DrawString(lbl_Descricao.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(90, 680, 405, page.Height));
                        }
                        else if (aux5 != "" || aux6 != "")
                        {
                            text_forma.DrawString(lbl_Exp.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 510, page.Width, page.Height));
                            grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 530, 492, 4);
                        }
                        if (aux5 != "")
                        {
                            text_forma.DrawString(lbl_Empresa1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 550, page.Width, page.Height));
                            text_forma.DrawString(lbl_Tempo_Empresa1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 565, page.Width, page.Height));
                        }

                        if (aux6 != "")
                        {
                            text_forma.DrawString(lbl_Empresa2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 580, page.Width, page.Height));
                            text_forma.DrawString(lbl_Tempo_Empresa2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 595, page.Width, page.Height));
                        }

                        if (aux7 != "")
                        {
                            text_forma.DrawString(lbl_Descricao.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(90, 680, 405, page.Height));
                        }
                        try
                        {
                            doc.Save("Currículo.pdf");
                            System.Diagnostics.Process.Start("Currículo.pdf");
                        }
                        catch
                        {
                            throw new Exception("Feche o pdf que já esta aberto!");
                        }
                    }
                }
                else
                {
                    using (var doc = new PdfSharp.Pdf.PdfDocument())
                    {
                        var page       = doc.AddPage();
                        var grafico    = PdfSharp.Drawing.XGraphics.FromPdfPage(page);
                        var text_forma = new PdfSharp.Drawing.Layout.XTextFormatter(grafico);
                        var fontT      = new PdfSharp.Drawing.XFont("Arial", 16);
                        var font       = new PdfSharp.Drawing.XFont("Arial", 13);

                        //Dados Pessoais
                        text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                        text_forma.DrawString(lbl_Nome.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 40, page.Width, page.Height));
                        text_forma.DrawString(lbl_nacionalidade.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 70, page.Width, page.Height));
                        text_forma.DrawString(lbl_Endereco.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 85, page.Width, page.Height));
                        text_forma.DrawString(lbl_Cidade.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 100, page.Width, page.Height));
                        text_forma.DrawString(lbl_Tel.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 115, page.Width, page.Height));
                        text_forma.DrawString(lbl_Email.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 130, page.Width, page.Height));

                        //Objetivo
                        text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                        text_forma.DrawString(lbl_Objetivo.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 180, page.Width, page.Height));
                        grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 200, 492, 4);
                        text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                        text_forma.DrawString(lbl_Area.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 220, page.Width, page.Height));
                        text_forma.DrawString(lbl_Cargo.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 235, page.Width, page.Height));

                        //Formação Acadêmica
                        text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                        text_forma.DrawString(lbl_formacao.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 285, page.Width, page.Height));
                        grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 305, 492, 4);
                        text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                        text_forma.DrawString(lbl_escolaridade.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 325, page.Width, page.Height));

                        if (aux1 != "" && aux2 != "" && aux3 != "" && aux4 != "")
                        {
                            //Atividades Extracurriculares
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                            text_forma.DrawString(lbl_Atividades.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 375, page.Width, page.Height));
                            grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 395, 492, 4);
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                            text_forma.DrawString(lbl_Curso1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 415, page.Width, page.Height));
                            text_forma.DrawString(lbl_Curso2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 430, page.Width, page.Height));
                            text_forma.DrawString(lbl_Idioma1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 445, page.Width, page.Height));
                            text_forma.DrawString(lbl_Idioma2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 460, page.Width, page.Height));
                        }
                        else if (aux1 != "" || aux2 != "" || aux3 != "" || aux4 != "")
                        {
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                            text_forma.DrawString(lbl_Atividades.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 375, page.Width, page.Height));
                            grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 395, 492, 4);
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                        }


                        if (aux1 != "")
                        {
                            text_forma.DrawString(lbl_Curso1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 415, page.Width, page.Height));
                        }

                        if (aux2 != "")
                        {
                            text_forma.DrawString(lbl_Curso2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 430, page.Width, page.Height));
                        }

                        if (aux3 != "")
                        {
                            text_forma.DrawString(lbl_Idioma1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 445, page.Width, page.Height));
                        }

                        if (aux4 != "")
                        {
                            text_forma.DrawString(lbl_Idioma2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 460, page.Width, page.Height));
                        }


                        if (aux5 != "" && aux6 != "")
                        {
                            //Experiência Profissional
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                            text_forma.DrawString(lbl_Exp.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 510, page.Width, page.Height));
                            grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 530, 492, 4);
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                            text_forma.DrawString(lbl_Empresa1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 550, page.Width, page.Height));
                            text_forma.DrawString(lbl_Tempo_Empresa1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 565, page.Width, page.Height));
                            text_forma.DrawString(lbl_Empresa2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 580, page.Width, page.Height));
                            text_forma.DrawString(lbl_Tempo_Empresa2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 595, page.Width, page.Height));
                            text_forma.DrawString(lbl_Descricao.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 680, 405, page.Height));
                        }
                        else if (aux5 != "" || aux6 != "")
                        {
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Center;
                            text_forma.DrawString(lbl_Exp.Text.ToString(), fontT, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(0, 510, page.Width, page.Height));
                            grafico.DrawRectangle(PdfSharp.Drawing.XPens.LightGray, PdfSharp.Drawing.XBrushes.LightGray, 50, 530, 492, 4);
                            text_forma.Alignment = PdfSharp.Drawing.Layout.XParagraphAlignment.Left;
                        }
                        if (aux5 != "")
                        {
                            text_forma.DrawString(lbl_Empresa1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 550, page.Width, page.Height));
                            text_forma.DrawString(lbl_Tempo_Empresa1.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 565, page.Width, page.Height));
                        }

                        if (aux6 != "")
                        {
                            text_forma.DrawString(lbl_Empresa2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 580, page.Width, page.Height));
                            text_forma.DrawString(lbl_Tempo_Empresa2.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 595, page.Width, page.Height));
                        }

                        if (aux7 != "")
                        {
                            text_forma.DrawString(lbl_Descricao.Text.ToString(), font, PdfSharp.Drawing.XBrushes.Black, new PdfSharp.Drawing.XRect(50, 680, 405, page.Height));
                        }
                        try
                        {
                            doc.Save("Currículo.pdf");
                            System.Diagnostics.Process.Start("Currículo.pdf");
                        }
                        catch
                        {
                            throw new Exception("Feche o pdf que já esta aberto!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "CurriculoGo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }