Exemple #1
0
        public static void ApplyLightTableStyle(this PdfLightTable pdfLightTable, PdfColor borderColor, PdfColor textColor, PdfColor altBackgroundColor, PdfColor altTextColor)
        {
            //TODO: Extension
            var retStyle = new PdfLightTableStyle
            {
                BorderPen    = new PdfPen(borderColor),
                DefaultStyle = new PdfCellStyle
                {
                    TextBrush = new PdfSolidBrush(textColor),
                    BorderPen = new PdfPen(borderColor)
                },
                AlternateStyle = new PdfCellStyle
                {
                    TextBrush       = new PdfSolidBrush(textColor),
                    BackgroundBrush = new PdfSolidBrush(altBackgroundColor),
                    BorderPen       = new PdfPen(borderColor)
                },
                ShowHeader   = true,
                RepeatHeader = true,
                HeaderSource = PdfHeaderSource.ColumnCaptions,
                HeaderStyle  = new PdfCellStyle
                {
                    BorderPen       = new PdfPen(borderColor),
                    BackgroundBrush = new PdfSolidBrush(borderColor),
                    TextBrush       = new PdfSolidBrush(altTextColor)
                }
            };

            pdfLightTable.Style = retStyle;
        }
Exemple #2
0
        public IActionResult GenTable()
        {
            PdfDocument document;

            document = new PdfDocument();
            PdfPage page = document.Pages.Add();

            PdfGraphics graphics = page.Graphics;

            PdfLightTable pdfLightTable = new PdfLightTable();

            pdfLightTable.DataSourceType = PdfLightTableDataSourceType.TableDirect;

            pdfLightTable.Columns.Add(new PdfColumn("Roll Number"));
            pdfLightTable.Columns.Add(new PdfColumn("Name"));
            pdfLightTable.Columns.Add(new PdfColumn("Class"));

            pdfLightTable.Rows.Add(new object[] { "111", "Luka", "III" });

            pdfLightTable.Draw(page, PointF.Empty);



            MemoryStream stream = new MemoryStream();

            document.Save(stream);

            stream.Position = 0;
            return(File(stream, "application/pdf", "test.pdf"));
        }
Exemple #3
0
        static void Main(string[] args)
        {
            //Create a new PDF document.
            PdfDocument doc = new PdfDocument();

            //Add a page.

            PdfPage page = doc.Pages.Add();

            // Create a PdfLightTable.

            PdfLightTable pdfLightTable = new PdfLightTable();

            // Initialize DataTable to assign as DateSource to the light table.

            DataTable table = new DataTable();

            //Include columns to the DataTable.

            table.Columns.Add("Name");

            table.Columns.Add("Age");

            table.Columns.Add("Sex");

            //Include rows to the DataTable.

            table.Rows.Add(new string[] { "abc", "21", "Male" });

            //Assign data source.

            pdfLightTable.DataSource = table;

            //Draw PdfLightTable.

            pdfLightTable.Draw(page, new PointF(0, 0));

            //Save the document.

            doc.Save("PdfTable.pdf");

            //Close the document

            doc.Close(true);

            //This will open the PDF file so, the result will be seen in default PDF viewer
            Process.Start("PdfTable.pdf");
        }
        private void BtnPK_Click(object sender, EventArgs e)
        {
            List <Sport> sport = new List <Sport>();

            sport = InfoWhole();
            //Create a new PDF document
            PdfDocument doc = new PdfDocument();
            //Add a page
            PdfPage page = doc.Pages.Add();
            // Create a PdfLightTable
            PdfLightTable pdfLightTable = new PdfLightTable();

            // Initialize DataTable to assign as DateSource to the light table
            System.Data.DataTable table = new System.Data.DataTable();
            //Include columns to the DataTable

            table.Columns.Add("Kalorije");
            table.Columns.Add("Vzpon distance");
            table.Columns.Add("Kadenca");
            table.Columns.Add("Avg kadenca");
            //Include rows to the DataTable
            int count = sport.Count;

            int stevec = 1;

            foreach (var item in sport)
            {
                table.Rows.Add(new string[] { item.Porabljene_kalorije, item.Skupen_vzpon, item.Max_kadenca, item.Povp_kadenca });
                stevec++;
            }

            //Applying cell padding to table
            pdfLightTable.Style.CellPadding = 3;
            pdfLightTable.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.GridTable3Accent3);
            //Assign data source
            pdfLightTable.DataSource = table;
            //Setting this property to true to show the header of table
            pdfLightTable.Style.ShowHeader = true;
            //Draw PdfLightTable
            pdfLightTable.Draw(page, new PointF(0, 0));
            //Save the document

            doc.Save("PdfTable.pdf");
            //Close the document
            doc.Close(true);
            //This will open the PDF file so, the result will be seen in default PDF viewer
            Process.Start("PdfTable.pdf");
        }
        private void BtnPDF_Click(object sender, EventArgs e)
        {
            List <Sport> sport = new List <Sport>();

            sport = Info();
            //Create a new PDF document
            Syncfusion.Pdf.PdfDocument doc = new PdfDocument();
            //Add a page
            PdfPage page = doc.Pages.Add();
            // Create a PdfLightTable
            PdfLightTable pdfLightTable = new PdfLightTable();

            // Initialize DataTable to assign as DateSource to the light table
            System.Data.DataTable table = new System.Data.DataTable();
            //Include columns to the DataTable

            table.Columns.Add("Kolesar");
            table.Columns.Add("Total distance");
            table.Columns.Add("Total calories");
            table.Columns.Add("Total time");
            //Include rows to the DataTable
            int count = sport.Count;

            int stevec = 1;

            foreach (var item in sport)
            {
                table.Rows.Add(new string[] { stevec.ToString(), item.Stevilo_prevozenih_km, item.Porabljene_kalorije, item.Trajanje_aktivnosti });
                stevec++;
            }

            //Applying cell padding to table
            pdfLightTable.Style.CellPadding = 3;
            pdfLightTable.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.GridTable3Accent3);
            //Assign data source
            pdfLightTable.DataSource = table;
            //Setting this property to true to show the header of table
            pdfLightTable.Style.ShowHeader = true;
            //Draw PdfLightTable
            pdfLightTable.Draw(page, new PointF(0, 0));
            //Save the document

            doc.Save("PdfTable.pdf");
            //Close the document
            doc.Close(true);
            //This will open the PDF file so, the result will be seen in default PDF viewer
            Process.Start("PdfTable.pdf");
        }
Exemple #6
0
 private void reportMenuItem_Click(object sender, RoutedEventArgs e)
 {
     using (PdfDocument doc = new PdfDocument())
     {
         PdfPage       page          = doc.Pages.Add();
         PdfLightTable pdfLightTable = new PdfLightTable();
         DataTable     table         = new DataTable();
         table.Columns.Add("Ime");
         table.Columns.Add("Prezime");
         table.Columns.Add("Datum rođenja");
         table.Rows.Add(new string[] { "Ime", "Prezime", "Datum rođenja" });
         foreach (Doctor doctor in DoctorController.getInstance().GetDoctors())
         {
             table.Rows.Add(new string[] { doctor.Name, doctor.Surname, doctor.DateOfBirth.ToLongDateString() });
         }
         pdfLightTable.DataSource = table;
         pdfLightTable.Draw(page, new PointF(0, 0));
         doc.Save("C:\\Users\\Mirko\\Desktop\\Izvestaj.pdf");
         doc.Close(true);
     }
     MessageBox.Show("HVALA NA POVRATNOJ INFORMACIJI!");
 }
Exemple #7
0
 private void CreateReport()
 {
     using (PdfDocument doc = new PdfDocument())
     {
         PdfPage       page          = doc.Pages.Add();
         PdfLightTable pdfLightTable = new PdfLightTable();
         DataTable     table         = new DataTable();
         table.Columns.Add("Lek");
         table.Columns.Add("Utrošena količina");
         table.Rows.Add(new string[] { "Lek", "Utrosena kolicina" });
         DateTime startDate = DateTime.ParseExact(startDateTextBox.Text,
                                                  "dd.MM.yyyy.", System.Globalization.CultureInfo.InvariantCulture);
         DateTime endDate = DateTime.ParseExact(endDateTextBox.Text,
                                                "dd.MM.yyyy.", System.Globalization.CultureInfo.InvariantCulture);
         foreach (Medicine medicine in MedicineController.GetInstance().GetAllMedicines())
         {
             int number = 0;
             foreach (Patient patient in PatientController.getInstance().getPatient())
             {
                 foreach (Prescription prescription in patient.MedicalRecord.getPrescriptions())
                 {
                     if (prescription.medicine.Name.Equals(medicine.Name) && prescription.startTime > startDate && prescription.startTime < endDate)
                     {
                         number++;
                     }
                 }
             }
             table.Rows.Add(new string[] { medicine.Name, number.ToString() });
         }
         pdfLightTable.DataSource = table;
         pdfLightTable.Draw(page, new PointF(0, 0));
         doc.Save("Lekovi.pdf");
         doc.Close(true);
     }
     MessageBox.Show("Uspesno kreiran izvestaj o potrosnji lekova");
 }
        private float GenerateItemizedBodyWithLightTable(GenerateInvoiceContext request, PdfGenerator pdf, float currentY)
        {
            float y = currentY + 10;

            PdfLightTable pdfLightTable = new PdfLightTable();

            pdfLightTable.ApplyLightTableStyle(pdf.PdfGridStyle2Color, pdf.AccentColor, pdf.PdfGridStyle2AltColor, new PdfColor(Color.White));

            pdfLightTable.DataSourceType = PdfLightTableDataSourceType.TableDirect;

            //Add columns to the DataTable
            var columnFormat = new PdfStringFormat
            {
                Alignment     = PdfTextAlignment.Center,
                LineAlignment = PdfVerticalAlignment.Middle
            };

            pdfLightTable.Columns.Add(new PdfColumn("Title")
            {
                StringFormat = columnFormat
            });
            pdfLightTable.Columns.Add(new PdfColumn("Cost")
            {
                StringFormat = columnFormat
            });
            pdfLightTable.Columns.Add(new PdfColumn("Qty")
            {
                StringFormat = columnFormat
            });
            pdfLightTable.Columns.Add(new PdfColumn("Total")
            {
                StringFormat = columnFormat
            });

            foreach (var item in request.Invoice.Items)
            {
                pdfLightTable.Rows.Add(new object[] { item.Name, item.ItemAmount.ToString("n2"), item.Quantity.ToString(), item.Amount.ToString("n2") });
            }

            //resize columns to content width - current a BUG in PdfLightTable implementation (works for PdfGrid)
            //ref: https://www.syncfusion.com/forums/131302/pdfgrid-size-grid-to-content

            //var data = request.Invoice.Items.Select(x => x.ItemAmount.ToString("n2"));
            //pdfLightTable.Columns[1].SizeColumnToContent(data, pdf.PageWidth, pdf.NormalFont);
            //data = request.Invoice.Items.Select(x => x.Quantity.ToString("n2"));
            //pdfLightTable.Columns[2].SizeColumnToContent(data, pdf.PageWidth, pdf.NormalFont);
            //data = request.Invoice.Items.Select(x => x.Amount.ToString("n2"));
            //pdfLightTable.Columns[3].SizeColumnToContent(data, pdf.PageWidth, pdf.NormalFont);

            PdfLightTableLayoutFormat layoutFormat = new PdfLightTableLayoutFormat();

            layoutFormat.Break          = PdfLayoutBreakType.FitPage;
            layoutFormat.Layout         = PdfLayoutType.Paginate;
            layoutFormat.PaginateBounds = new RectangleF(0, 0, pdf.CurrentPage.Graphics.ClientSize.Width, pdf.CurrentPage.Graphics.ClientSize.Height - FOOTER_HEIGHT);

            var result = pdfLightTable.Draw(pdf.CurrentPage, new PointF(10, y), layoutFormat);

            y = result.Bounds.Bottom;
            y = pdf.IncrementY(y, 0, FOOTER_HEIGHT);

            return(y);
        }
Exemple #9
0
        private void ExportToPDF(object sender, RoutedEventArgs e)
        {
            if (!evaluatedFunctionsList.Any() || !algorithmParametersList.Any())
            {
                if (MessageBox.Show("Add parameters first", "No parameters error", MessageBoxButton.OK, MessageBoxImage.Error) == MessageBoxResult.OK)
                {
                    return;
                }
            }
            using (PdfDocument document = new PdfDocument())
            {
                foreach (var ga in genericAlgorithmsList)
                {
                    //Add a page to the document
                    PdfPage page = document.Pages.Add();

                    ////Create PDF graphics for a page
                    PdfGraphics graphics = page.Graphics;

                    //Set the standard font
                    PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 13);

                    //Draw the text
                    String functionString = "Function: " +
                                            ga.evaluatedFunction.function.getFunctionExpressionString() +
                                            " x:<" + ga.evaluatedFunction.xDomain.X.ToString() +
                                            "," + ga.evaluatedFunction.xDomain.Y.ToString() +
                                            " > y:<" + ga.evaluatedFunction.yDomain.X.ToString() +
                                            "," + ga.evaluatedFunction.yDomain.Y.ToString() + ">";

                    graphics.DrawString(functionString, font, PdfBrushes.Black, new PointF(0, 0));


                    //Draw the text
                    graphics.DrawString("Parameters", font, PdfBrushes.Black, new PointF(0, 20));


                    // Create a PdfLightTable.

                    PdfLightTable pdfLightTable = new PdfLightTable();

                    // Initialize DataTable to assign as DateSource to the light table.

                    DataTable table = new DataTable();

                    //Include columns to the DataTable.

                    table.Columns.Add("Crossover probability");
                    table.Columns.Add("Mutation probability");
                    table.Columns.Add("Population");
                    table.Columns.Add("Generations");
                    table.Columns.Add("Precision");
                    table.Columns.Add("IsMaxSearching");
                    //Include rows to the DataTable.

                    table.Rows.Add(new string[] {
                        ga.algorithmParameters.CrossoverProbability.ToString(),
                        ga.algorithmParameters.MutationProbability.ToString(),
                        ga.algorithmParameters.Population.ToString(),
                        ga.algorithmParameters.Generations.ToString(),
                        ga.algorithmParameters.Precision.ToString(),
                        ga.algorithmParameters.isMaxSearching.ToString()
                    });

                    //Assign data source.

                    pdfLightTable.DataSource       = table;
                    pdfLightTable.Style.ShowHeader = true;

                    //Draw PdfLightTable.

                    pdfLightTable.Draw(page, new PointF(0, 40));

                    //Draw the text
                    graphics.DrawString("Summary", font, PdfBrushes.Black, new PointF(0, 60));

                    // Create a PdfLightTable.

                    PdfLightTable summary = new PdfLightTable();

                    // Initialize DataTable to assign as DateSource to the light table.

                    DataTable summaryTable = new DataTable();

                    //Include columns to the DataTable.

                    summaryTable.Columns.Add("Generation");
                    summaryTable.Columns.Add("Best solution");
                    summaryTable.Columns.Add("Median solution");
                    summaryTable.Columns.Add("Mean solution");

                    //Include rows to the DataTable.
                    for (int generation = 0; generation < ga.algorithmParameters.Generations; generation++)
                    {
                        summaryTable.Rows.Add(new string[] {
                            (generation + 1).ToString(),
                            ga.BestValues[generation].ToString(),
                            ga.MedianValues[generation].ToString(),
                            ga.MeanValues[generation].ToString(),
                        });
                    }


                    //Assign data source.

                    summary.DataSource       = summaryTable;
                    summary.Style.ShowHeader = true;

                    //Draw PdfLightTable.

                    summary.Draw(page, new PointF(0, 80));
                }

                //Save the document
                document.Save("Output.pdf");

                #region View the Workbook
                //Message box confirmation to view the created document.
                if (MessageBox.Show("Do you want to view the PDF?", "PDF has been created",
                                    MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                {
                    try
                    {
                        //Launching the Excel file using the default Application.[MS Excel Or Free ExcelViewer]
                        System.Diagnostics.Process.Start("Output.pdf");
                    }
                    catch (Win32Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }
                #endregion
            }
        }
        private void ReportButton_Click(object sender, RoutedEventArgs e)
        {
            PdfDocument   doc           = new PdfDocument();
            PdfPage       page          = doc.Pages.Add();
            PdfLightTable pdfLightTable = new PdfLightTable();
            DataTable     table         = new DataTable();

            pdfLightTable.Style.ShowHeader = true;

            PdfCellStyle headerStyle = new PdfCellStyle(new PdfStandardFont(PdfFontFamily.Helvetica, 10), PdfBrushes.DarkBlue, PdfPens.DarkBlue);

            pdfLightTable.Style.HeaderStyle = headerStyle;

            table.Columns.Add("PONEDELJAK");
            table.Columns.Add("UTORAK");
            table.Columns.Add("SREDA");
            table.Columns.Add("ČETVRTAK");
            table.Columns.Add("PETAK");
            table.Columns.Add("SUBOTA");
            table.Columns.Add("NEDELJA");

            DateTime        startOfWeek          = DateTime.Today.AddDays(-1 * (int)(DateTime.Today.DayOfWeek));
            DateTime        endOfWeek            = startOfWeek.AddDays(7).AddSeconds(-1);
            List <DateTime> datesCurrentWeek     = new List <DateTime>();
            List <String>   mondayTherapyInfo    = new List <String>();
            List <String>   tuesdayTherapyInfo   = new List <String>();
            List <String>   wednesdayTherapyInfo = new List <String>();
            List <String>   thursdayTherapyInfo  = new List <String>();
            List <String>   fridayTherapyInfo    = new List <String>();
            List <String>   saturdayTherapyInfo  = new List <String>();
            List <String>   sundayTherapyInfo    = new List <String>();

            for (var date = startOfWeek; date <= endOfWeek; date = date.AddDays(1))
            {
                datesCurrentWeek.Add(date);
            }

            foreach (var therapy in _loggedInPatient.MedicalRecord.getPrescriptions())
            {
                foreach (var currentDate in datesCurrentWeek)
                {
                    foreach (var therapyDate in GetTherapyDates(therapy))
                    {
                        if (therapyDate == currentDate)
                        {
                            switch (therapyDate.DayOfWeek)
                            {
                            case DayOfWeek.Monday:
                                mondayTherapyInfo.Add(therapy.medicine.Name + "-" + therapy.info);
                                break;

                            case DayOfWeek.Tuesday:
                                tuesdayTherapyInfo.Add(therapy.medicine.Name + "-" + therapy.info);
                                break;

                            case DayOfWeek.Wednesday:
                                wednesdayTherapyInfo.Add(therapy.medicine.Name + "-" + therapy.info);
                                break;

                            case DayOfWeek.Thursday:
                                thursdayTherapyInfo.Add(therapy.medicine.Name + "-" + therapy.info);
                                break;

                            case DayOfWeek.Friday:
                                fridayTherapyInfo.Add(therapy.medicine.Name + "-" + therapy.info);
                                break;

                            case DayOfWeek.Saturday:
                                saturdayTherapyInfo.Add(therapy.medicine.Name + "-" + therapy.info);
                                break;

                            case DayOfWeek.Sunday:
                                sundayTherapyInfo.Add(therapy.medicine.Name + "-" + therapy.info);
                                break;
                            }
                        }
                    }
                }
            }

            int[] numberOfTherapiesInDays = { mondayTherapyInfo.Count, tuesdayTherapyInfo.Count,  wednesdayTherapyInfo.Count, thursdayTherapyInfo.Count,
                                              fridayTherapyInfo.Count, saturdayTherapyInfo.Count, sundayTherapyInfo.Count };

            fillTherapyInformation(mondayTherapyInfo, numberOfTherapiesInDays);
            fillTherapyInformation(tuesdayTherapyInfo, numberOfTherapiesInDays);
            fillTherapyInformation(wednesdayTherapyInfo, numberOfTherapiesInDays);
            fillTherapyInformation(thursdayTherapyInfo, numberOfTherapiesInDays);
            fillTherapyInformation(fridayTherapyInfo, numberOfTherapiesInDays);
            fillTherapyInformation(saturdayTherapyInfo, numberOfTherapiesInDays);
            fillTherapyInformation(sundayTherapyInfo, numberOfTherapiesInDays);

            for (int i = 0; i <= numberOfTherapiesInDays.Max(); i++)
            {
                table.Rows.Add(new string[] { mondayTherapyInfo[i], tuesdayTherapyInfo[i], wednesdayTherapyInfo[i], thursdayTherapyInfo[i],
                                              fridayTherapyInfo[i], saturdayTherapyInfo[i], sundayTherapyInfo[i] });
            }

            pdfLightTable.DataSource = table;
            pdfLightTable.Draw(page, new PointF(0, 0));
            doc.Save(DateTime.Now.Day + "_" + DateTime.Now.Month + "_" + DateTime.Now.Year + ".pdf");
            doc.Close(true);
        }
Exemple #11
0
        public void Generate(int id)
        {
            Order order = data.getOrder(id);

            List <OrderedProduct> products = data.GetOrderedProducts(id);

            using (PdfDocument document = new PdfDocument())
            {
                //Add a page to the document
                PdfPage page = document.Pages.Add();

                //Create PDF graphics for a page
                PdfGraphics graphics = page.Graphics;

                //Set the standard font
                PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);

                //Draw the text
                graphics.DrawString("Faktura z dnia: " + $"{order.OrderDate.ToShortDateString()}r.", font, PdfBrushes.Black, new System.Drawing.PointF(0, 0));
                font = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
                graphics.DrawString("Kupiec: " + $"{order.Firstname}" + $" {order.Lastname}" + $" (PESEL: {order.Pesel})", font, PdfBrushes.Black, new System.Drawing.PointF(0, 25));

                font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
                graphics.DrawString("Lista produktów: ", font, PdfBrushes.Black, new System.Drawing.PointF(0, 60));

                // DataTable with ordered products
                PdfLightTable pdfLightTable = new PdfLightTable();
                DataTable     table         = new DataTable();
                table.Columns.Add("Lp.");
                table.Columns.Add("Nazwa");
                table.Columns.Add("Ilosc");
                table.Columns.Add("Cena");
                table.Columns.Add("VAT");

                int lp = 1;
                table.Rows.Add(new string[] { "Lp.", "Nazwa", "Ilosc", "Cena", "VAT" });
                foreach (OrderedProduct product in products)
                {
                    table.Rows.Add(new string[] { $"{lp++}", $"{product.Name}", $"{product.Count}", $"{product.Price} zl", $"{product.VAT} %" });
                }

                pdfLightTable.DataSource = table;
                pdfLightTable.Draw(page, new System.Drawing.PointF(0, 100));

                font = new PdfStandardFont(PdfFontFamily.Helvetica, 15);
                graphics.DrawString("Do zaplaty: " + $"{String.Format("{0:0.00}", order.TotalCost)} zl", font, PdfBrushes.Black, new System.Drawing.PointF(320, 0));


                // Path to save
                string fileName = "";
                Microsoft.Win32.OpenFileDialog diag = new Microsoft.Win32.OpenFileDialog();
                diag.ValidateNames   = false;
                diag.CheckFileExists = false;
                diag.CheckPathExists = true;
                diag.FileName        = "Faktura_" + $"{order.Firstname}_" + $"{order.Lastname}_" + $"{order.OrderDate.ToShortDateString()}";
                if (diag.ShowDialog() == true)
                {
                    fileName = diag.FileName;
                }


                //Save the document
                try
                {
                    document.Save(fileName + ".pdf");
                    System.Windows.MessageBox.Show("Pomyślnie zapisano dokument", "Sukces", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show("Wystąpił błąd: " + ex.Message);
                }
            }
        }
Exemple #12
0
        public MemoryStream testc( )
        {
            var text = "Blaze Boilers & Fires";


            PdfDocument doc = new PdfDocument();


            //Adds a page.
            PdfPage page = doc.Pages.Add();

            //create a new PDF string format
            PdfStringFormat drawFormat = new PdfStringFormat();

            drawFormat.WordWrap      = PdfWordWrapType.Word;
            drawFormat.Alignment     = PdfTextAlignment.Justify;
            drawFormat.LineAlignment = PdfVerticalAlignment.Top;
            PdfTemplate header = AddHeader(doc, text, "Header and Footer Demo");

            page.Graphics.DrawPdfTemplate(header, new PointF());

            PdfFont  headFont = new PdfStandardFont(PdfFontFamily.Helvetica, 16f);
            PdfBrush brush    = PdfBrushes.Red;

            RectangleF headerBounds = new RectangleF(0, 0, doc.Pages[0].GetClientSize().Width, 50);

            //PdfPageTemplateElement header = new PdfPageTemplateElement(headerBounds);
            //PdfTextElement elementHead = new PdfTextElement(text, headFont, brush);

            //Set the string format
            //elementHead.StringFormat = drawFormat;

            //Draw the text element
            // PdfLayoutResult resultHead = elementHead.Draw(page, headerBounds);
            // doc.Template.Top = header;



            //bounds
            RectangleF bounds = new RectangleF(new PointF(20, 20), new SizeF(page.Graphics.ClientSize.Width - 30, page.Graphics.ClientSize.Height - 20));

            //Create a new text elememt
            PdfTextElement element = new PdfTextElement("01293400400", headFont, brush);

            //Set the string format
            element.StringFormat = drawFormat;

            //Draw the text element
            PdfLayoutResult result = element.Draw(page, bounds);

            // Draw the string one after another.
            result = element.Draw(result.Page, new RectangleF(result.Bounds.X, result.Bounds.Bottom + 10, result.Bounds.Width, result.Bounds.Height));

            // Creates a PdfLightTable.
            PdfLightTable pdfLightTable = new PdfLightTable();

            //Add colums to light table
            pdfLightTable.Columns.Add(new PdfColumn("Item"));
            pdfLightTable.Columns.Add(new PdfColumn("Description"));
            pdfLightTable.Columns.Add(new PdfColumn("Cost"));

            //Add row
            pdfLightTable.Rows.Add(new string[] { "abc", "21", "Male" });


            PdfLightTable totalTable = new PdfLightTable();

            totalTable.Columns.Add(new PdfColumn("Total"));
            totalTable.Rows.Add(new string[] { "£34" });


            //Includes the style to display the header of the light table.
            pdfLightTable.Style.ShowHeader = true;

            //Draws PdfLightTable and returns the rendered bounds.
            result = pdfLightTable.Draw(page, new PointF(result.Bounds.Left, result.Bounds.Bottom + 20));

            //draw string with returned bounds from table
            result = element.Draw(result.Page, result.Bounds.X, result.Bounds.Bottom + 10);

            //draw string with returned bounds from table
            element.Draw(result.Page, result.Bounds.X, result.Bounds.Bottom + 10);
            MemoryStream stream = new MemoryStream();

            doc.Save(stream);

            return(stream);
        }
        private async Task onLogout(object sender, EventArgs f)
        {
            var fbClient = new FirebaseClient("https://conference-686e4.firebaseio.com/");


            if (User.Email == cf.CreatorEmail)
            {
                fbClient.Child("Conference/" + ConferenceKey.ConKey).Child("Status").PutAsync(false);

                var userList = (await fbClient.Child("Conference/" + ConferenceKey.ConKey + "/Members").OnceAsync <Members>()).
                               Select((item) =>

                                      new Members
                {
                    MemberEmail = item.Object.MemberEmail
                }

                                      ).ToList();



                var questionList = (await fbClient.Child("Conference/" + ConferenceKey.ConKey + "/Questions").OnceAsync <Questions>()).OrderByDescending(m => m.Object.Point).Take(5).
                                   Select((item) =>

                                          new Questions
                {
                    Key       = item.Key,
                    UserEmail = item.Object.UserEmail,
                    Point     = item.Object.Point,
                    Question  = item.Object.Question
                }

                                          ).ToList();



                string text = "Konferans Ismi: " + cf.ConferenceName + "  " + "Konferans Yöneticisi: " + cf.CreaterName + " " + cf.CreaterSurname + " Toplam kullanici sayi: " + userList.Count();

                //Creates a new PDF document.
                PdfDocument doc = new PdfDocument();

                //Adds a page.
                PdfPage page = doc.Pages.Add();

                //create a new PDF string format
                PdfStringFormat drawFormat = new PdfStringFormat();
                drawFormat.WordWrap      = PdfWordWrapType.Word;
                drawFormat.Alignment     = PdfTextAlignment.Justify;
                drawFormat.LineAlignment = PdfVerticalAlignment.Top;

                //Set the font.
                PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);

                //Create a brush.
                PdfBrush brush = PdfBrushes.Red;

                //bounds
                RectangleF bounds = new RectangleF(new PointF(10, 10), new SizeF(page.Graphics.ClientSize.Width - 30, page.Graphics.ClientSize.Height - 20));

                //Create a new text elememt
                PdfTextElement element = new PdfTextElement(text, font, brush);

                //Set the string format
                element.StringFormat = drawFormat;

                //Draw the text element
                PdfLayoutResult result = element.Draw(page, bounds);

                // Draw the string one after another.

                // Creates a PdfLightTable.
                PdfLightTable QuestionTable = new PdfLightTable();

                //Add colums to light table
                QuestionTable.Columns.Add(new PdfColumn("Gönderen Kullanıcı"));
                QuestionTable.Columns.Add(new PdfColumn("Soru"));
                QuestionTable.Columns.Add(new PdfColumn("Puan"));


                for (int i = 0; i < questionList.Count(); i++)
                {
                    QuestionTable.Rows.Add(new string[] { questionList[i].UserEmail, questionList[i].Question, questionList[i].Point.ToString() });
                }


                QuestionTable.Style.ShowHeader = true;


                result = QuestionTable.Draw(page, new PointF(result.Bounds.Left, result.Bounds.Bottom + 20));


                PdfLightTable UserTable = new PdfLightTable();

                //Add colums to light table
                UserTable.Columns.Add(new PdfColumn("Kullanıcı Epostas"));



                for (int i = 0; i < userList.Count(); i++)
                {
                    UserTable.Rows.Add(new string[] { userList[i].MemberEmail });
                }


                UserTable.Style.ShowHeader = true;


                result = UserTable.Draw(page, new PointF(result.Bounds.Left, result.Bounds.Bottom + 20));



                MemoryStream stream = new MemoryStream();


                doc.Save(stream);

                doc.Close(true);

                await DependencyService.Get <ISave>().SaveTextAsync("Conference.pdf", "application/pdf", stream);
            }
            else
            {
                await Navigation.PushModalAsync(new LoginPage());
            }
        }
Exemple #14
0
        public static void MakeTourPDF(Tour tour, string filename = null)
        {
            string file = "";

            if (filename == null)
            {
                file = filepath + tour.Name + ".pdf";// aus .config auslesen
            }
            else
            {
                file = filepath + filename + ".pdf";
            }

            FileStream  fs       = File.Open(file, FileMode.Create);
            PdfDocument document = new PdfDocument();

            PdfPage page = document.Pages.Add();

            PdfGraphics graphics = page.Graphics;

            //MAKE TEXT
            graphics.DrawString("Tour: " + tour.Name, headerFont, PdfBrushes.Black, new PointF(0, 0));
            graphics.DrawString("From: " + tour.StartLocation + "\n To: " + tour.EndLocation, normalFont, PdfBrushes.Black, new PointF(0, 30));
            graphics.DrawString("Description:\n" + tour.Description, normalFont, PdfBrushes.Black, new PointF(0, 60));


            PdfBitmap image;

            //MAKE IMAGE
            try
            {
                string     path      = imagePath + tour.MapImagePath;
                FileStream imgStream = new FileStream(path, FileMode.Open, FileAccess.Read);
                image = new PdfBitmap(imgStream);
            }
            catch (Exception e)
            {
                log.Info(String.Format("No Image Found for Tour: {0} \n  Error: {1}", tour.ID, e.Message));
                string     path      = FALLBACKIMAGE;
                FileStream imgStream = new FileStream(path, FileMode.Open, FileAccess.Read);
                image = new PdfBitmap(imgStream);
            }

            graphics.DrawImage(image, 300, 30, 200, 200);

            if (tour.LogList.Count > 0)
            {
                //MAKE TABLE
                PdfLightTable table = new PdfLightTable();
                table.DataSourceType = PdfLightTableDataSourceType.External;
                List <object> datalist = new List <object>();

                foreach (Log log in tour.LogList)
                {
                    object tmp = new { Date = log.Date, Report = log.Report, Distance = log.Distance, Rating = log.Rating, Steps = log.Steps, Duration = log.Duration, WeightKG = log.WeightKG, Feeling = log.Feeling, Weather = log.Weather, BloodPreassure = log.BloodPreassure };
                    datalist.Add(tmp);
                }

                table.Style.ShowHeader = true;
                table.DataSource       = datalist;
                table.Draw(page, new PointF(0, 250));
            }

            document.Save(fs);

            document.Close(true);
            fs.Close();

            //open after creating
            var p = new Process {
                StartInfo = new ProcessStartInfo(file)
                {
                    UseShellExecute = true
                }
            };

            p.Start();


            return;
        }
Exemple #15
0
        private void ReportsView_Click(object sender, RoutedEventArgs e)
        {
            var viewBtn = (Button)sender;
            var period  = viewBtn.DataContext as PeriodModel;

            if (period == null)
            {
                return;
            }

            int periodId   = period.Id;
            var reportData = GetReportData(periodId);

            if (!reportData.Any())
            {
                MessageBox.Show("Unable to generate the report for the selected period: no data available!");
                return;
            }

            using (var doc = new PdfDocument())
            {
                PdfPage page = doc.Pages.Add();

                //Create PDF graphics for a page
                PdfGraphics graphics = page.Graphics;

                var bounds = new RectangleF(0, 0, doc.Pages[0].GetClientSize().Width, 50);
                var header = new PdfPageTemplateElement(bounds);
                doc.Template.Top = header;

                PdfFont        subHeadingFont = new PdfTrueTypeFont(new Font("Microsoft Sans Serif", 14, System.Drawing.FontStyle.Bold), 14, true);
                PdfTextElement element        = new PdfTextElement($"ACCRUALS FOR {period.Name}", subHeadingFont);

                PdfLayoutResult result = element.Draw(page, new PointF(page.GetClientSize().Width / 2, bounds.Top + 8));
                graphics.DrawLine(new PdfPen(PdfBrushes.Black), new PointF(0, result.Bounds.Top + 20), new PointF(page.GetClientSize().Width, result.Bounds.Top + 20));

                //Set the standard font
                var font = new PdfTrueTypeFont(new Font("Microsoft Sans Serif", 11), true);
                var from = new PointF(0, result.Bounds.Top + 40);

                foreach (var reportEntry in reportData)
                {
                    House          house   = reportEntry.House;
                    PdfTextElement address = new PdfTextElement($"Address: {house.City} {house.Street} {house.HouseNumber} {house.CaseNumber}", font);
                    result = address.Draw(page, from);
                    from.Y = result.Bounds.Top + 20;
                    PdfLightTable pdfLightTable = new PdfLightTable();
                    pdfLightTable.Style.ShowHeader = true;

                    DataTable table = new DataTable();

                    table.Columns.Add("Owner");
                    table.Columns.Add("Flat Number");
                    table.Columns.Add("Living Space");
                    table.Columns.Add("Total (RUB)");

                    foreach (var flatEntry in reportEntry.Entries)
                    {
                        table.Rows.Add(new[]
                        {
                            flatEntry.Account.Owner,
                            flatEntry.Account.ApartmentNumber.ToString(),
                            flatEntry.Account.LivingSpace.ToString(),
                            flatEntry.Accruals.ToString()
                        });
                    }

                    pdfLightTable.DataSource = table;

                    result = pdfLightTable.Draw(page, from);
                    from.Y = result.Bounds.Bottom + 20;
                }
                //Draw the text

                //Save the document
                doc.Save("Output.pdf");

                string fileName = "Output.pdf";
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo.FileName = fileName;
                process.Start();
                process.WaitForExit();
            }
        }
Exemple #16
0
        public ActionResult InteractiveFeatures(string InsideBrowser)
        {
            #region Field Definitions
            document = new PdfDocument();
            document.PageSettings.Margins.All = 0;
            document.PageSettings.Size        = new SizeF(PdfPageSize.A4.Width, 600);
            interactivePage = document.Pages.Add();
            PdfGraphics g    = interactivePage.Graphics;
            RectangleF  rect = new RectangleF(0, 0, interactivePage.Graphics.ClientSize.Width, 100);

            PdfBrush whiteBrush  = new PdfSolidBrush(white);
            PdfPen   whitePen    = new PdfPen(white, 5);
            PdfBrush purpleBrush = new PdfSolidBrush(new PdfColor(255, 158, 0, 160));
            PdfFont  font        = new PdfStandardFont(PdfFontFamily.Helvetica, 25);
            Syncfusion.Drawing.Color maroonColor = Color.FromArgb(255, 188, 32, 60);
            Syncfusion.Drawing.Color orangeColor = Color.FromArgb(255, 255, 167, 73);
            #endregion

            #region Header
            g.DrawRectangle(purpleBrush, rect);
            g.DrawPie(whitePen, whiteBrush, new RectangleF(-20, 35, 700, 200), 20, -180);
            g.DrawRectangle(whiteBrush, new RectangleF(0, 99.5f, 700, 200));
            g.DrawString("Invoice", new PdfStandardFont(PdfFontFamily.TimesRoman, 24), PdfBrushes.White, new PointF(500, 10));

            string basePath = _hostingEnvironment.WebRootPath;
            string dataPath = string.Empty;
            dataPath = basePath + @"/PDF/";

            //Read the file
            FileStream file = new FileStream(dataPath + "AdventureCycle.jpg", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

            g.DrawImage(PdfImage.FromStream(file), new RectangleF(100, 70, 390, 130));
            #endregion

            #region Body

            //Invoice Number
            Random invoiceNumber = new Random();
            g.DrawString("Invoice No: " + invoiceNumber.Next().ToString(), new PdfStandardFont(PdfFontFamily.Helvetica, 14), new PdfSolidBrush(maroonColor), new PointF(50, 210));
            g.DrawString("Date: ", new PdfStandardFont(PdfFontFamily.Helvetica, 14), new PdfSolidBrush(maroonColor), new PointF(350, 210));

            //Current Date
            PdfTextBoxField textBoxField = new PdfTextBoxField(interactivePage, "date");
            textBoxField.Font          = new PdfStandardFont(PdfFontFamily.Helvetica, 12);
            textBoxField.Bounds        = new RectangleF(384, 204, 150, 30);
            textBoxField.ForeColor     = new PdfColor(maroonColor);
            textBoxField.ReadOnly      = true;
            document.Actions.AfterOpen = new PdfJavaScriptAction(@"var newdate = new Date(); 
            var thisfieldis = this.getField('date');  
            
            var theday = util.printd('dddd',newdate); 
            var thedate = util.printd('d',newdate); 
            var themonth = util.printd('mmmm',newdate);
            var theyear = util.printd('yyyy',newdate);  
            
            thisfieldis.strokeColor=color.transparent;
            thisfieldis.value = theday + ' ' + thedate + ', ' + themonth + ' ' + theyear ;");
            document.Form.Fields.Add(textBoxField);

            //invoice table
            PdfLightTable table = new PdfLightTable();
            table.Style.ShowHeader = true;
            g.DrawRectangle(new PdfSolidBrush(Syncfusion.Drawing.Color.FromArgb(238, 238, 238, 248)), new RectangleF(50, 240, 500, 140));

            //Header Style
            PdfCellStyle headerStyle = new PdfCellStyle();
            headerStyle.Font            = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold);
            headerStyle.TextBrush       = whiteBrush;
            headerStyle.StringFormat    = new PdfStringFormat(PdfTextAlignment.Center);
            headerStyle.BackgroundBrush = new PdfSolidBrush(orangeColor);
            headerStyle.BorderPen       = new PdfPen(whiteBrush, 0);
            table.Style.HeaderStyle     = headerStyle;

            //Cell Style
            PdfCellStyle bodyStyle = new PdfCellStyle();
            bodyStyle.Font           = new PdfStandardFont(PdfFontFamily.Helvetica, 10);
            bodyStyle.StringFormat   = new PdfStringFormat(PdfTextAlignment.Left);
            bodyStyle.BorderPen      = new PdfPen(whiteBrush, 0);
            table.Style.DefaultStyle = bodyStyle;
            table.DataSource         = GetProductReport(_hostingEnvironment.WebRootPath);
            table.Columns[0].Width   = 90;
            table.Columns[1].Width   = 160;
            table.Columns[3].Width   = 100;
            table.Columns[4].Width   = 65;
            table.Style.CellPadding  = 3;
            table.BeginCellLayout   += table_BeginCellLayout;

            PdfLightTableLayoutResult result = table.Draw(interactivePage, new RectangleF(50, 240, 500, 140));

            g.DrawString("Grand Total:", new PdfStandardFont(PdfFontFamily.Helvetica, 12), new PdfSolidBrush(Syncfusion.Drawing.Color.FromArgb(255, 255, 167, 73)), new PointF(result.Bounds.Right - 150, result.Bounds.Bottom));
            CreateTextBox(interactivePage, "GrandTotal", "Grand Total", new RectangleF(result.Bounds.Width - 15, result.Bounds.Bottom - 2, 66, 18), true, "");


            //Send to Server
            PdfButtonField sendButton = new PdfButtonField(interactivePage, "OrderOnline");
            sendButton.Bounds      = new RectangleF(200, result.Bounds.Bottom + 70, 80, 25);
            sendButton.BorderColor = white;
            sendButton.BackColor   = maroonColor;
            sendButton.ForeColor   = white;
            sendButton.Text        = "Order Online";
            PdfSubmitAction submitAction = new PdfSubmitAction("http://stevex.net/dump.php");
            submitAction.DataFormat    = SubmitDataFormat.Html;
            sendButton.Actions.MouseUp = submitAction;
            document.Form.Fields.Add(sendButton);

            //Order by Mail
            PdfButtonField sendMail = new PdfButtonField(interactivePage, "sendMail");
            sendMail.Bounds      = new RectangleF(300, result.Bounds.Bottom + 70, 80, 25);
            sendMail.Text        = "Order By Mail";
            sendMail.BorderColor = white;
            sendMail.BackColor   = maroonColor;
            sendMail.ForeColor   = white;

            // Create a javascript action.
            PdfJavaScriptAction javaAction = new PdfJavaScriptAction("address = app.response(\"Enter an e-mail address.\",\"SEND E-MAIL\",\"\");"
                                                                     + "var aSubmitFields = [];"
                                                                     + "for( var i = 0 ; i < this.numFields; i++){"
                                                                     + "aSubmitFields[i] = this.getNthFieldName(i);"
                                                                     + "}"
                                                                     + "if (address){ cmdLine = \"mailto:\" + address;this.submitForm(cmdLine,true,false,aSubmitFields);}");

            sendMail.Actions.MouseUp = javaAction;
            document.Form.Fields.Add(sendMail);

            //Print
            PdfButtonField printButton = new PdfButtonField(interactivePage, "print");
            printButton.Bounds          = new RectangleF(400, result.Bounds.Bottom + 70, 80, 25);
            printButton.BorderColor     = white;
            printButton.BackColor       = maroonColor;
            printButton.ForeColor       = white;
            printButton.Text            = "Print";
            printButton.Actions.MouseUp = new PdfJavaScriptAction("this.print (true); ");
            document.Form.Fields.Add(printButton);
            file = new FileStream(dataPath + "Product Catalog.pdf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            PdfAttachment attachment = new PdfAttachment("Product Catalog.pdf", file);
            attachment.ModificationDate = DateTime.Now;
            attachment.Description      = "Specification";
            document.Attachments.Add(attachment);

            //Open Specification
            PdfButtonField openSpecificationButton = new PdfButtonField(interactivePage, "openSpecification");
            openSpecificationButton.Bounds          = new RectangleF(50, result.Bounds.Bottom + 20, 87, 15);
            openSpecificationButton.TextAlignment   = PdfTextAlignment.Left;
            openSpecificationButton.Font            = new PdfStandardFont(PdfFontFamily.Helvetica, 10);
            openSpecificationButton.BorderStyle     = PdfBorderStyle.Underline;
            openSpecificationButton.BorderColor     = orangeColor;
            openSpecificationButton.BackColor       = new PdfColor(255, 255, 255);
            openSpecificationButton.ForeColor       = orangeColor;
            openSpecificationButton.Text            = "Open Specification";
            openSpecificationButton.Actions.MouseUp = new PdfJavaScriptAction("this.exportDataObject({ cName: 'Product Catalog.pdf', nLaunch: 2 });");
            document.Form.Fields.Add(openSpecificationButton);

            RectangleF     uriAnnotationRectangle = new RectangleF(interactivePage.Graphics.ClientSize.Width - 160, interactivePage.Graphics.ClientSize.Height - 30, 80, 20);
            PdfTextWebLink linkAnnot = new PdfTextWebLink();
            linkAnnot.Url   = "http://www.adventure-works.com";
            linkAnnot.Text  = "http://www.adventure-works.com";
            linkAnnot.Font  = new PdfStandardFont(PdfFontFamily.Helvetica, 8);
            linkAnnot.Brush = PdfBrushes.White;
            linkAnnot.DrawTextWebLink(interactivePage, uriAnnotationRectangle.Location);
            #endregion

            #region Footer
            g.DrawRectangle(purpleBrush, new RectangleF(0, interactivePage.Graphics.ClientSize.Height - 100, interactivePage.Graphics.ClientSize.Width, 100));
            g.DrawPie(whitePen, whiteBrush, new RectangleF(-20, interactivePage.Graphics.ClientSize.Height - 250, 700, 200), 0, 180);
            #endregion

            //Save the PDF to the MemoryStream
            MemoryStream ms = new MemoryStream();

            document.Save(ms);

            //If the position is not set to '0' then the PDF will be empty.
            ms.Position = 0;

            //Close the PDF document.
            document.Close(true);

            //Download the PDF document in the browser.
            FileStreamResult fileStreamResult = new FileStreamResult(ms, "application/pdf");
            fileStreamResult.FileDownloadName = "Interactive features.pdf";
            return(fileStreamResult);
        }
Exemple #17
0
        private string processMatNew(int[,] mtx, int height, int width, float scale)
        {
            var bookSegs    = new List <List <Segment> >();
            int maxSegCount = 0;

            for (int j = 0; j < width; j++)
            {//new page
                var  pageSegs   = new List <Segment>();
                int  begin      = -1;
                bool lookForEnd = false;
                for (int i = 0; i < height; i++)
                {//new pixel
                    Segment segment = new Segment();
                    segment.page = j + 1;

                    if (!lookForEnd)
                    {
                        if (mtx[i, j] == 1)//layer 1
                        {
                            lookForEnd    = true;
                            begin         = i;
                            segment.layer = 1;//layer 1
                        }
                    }
                    else if (mtx[i, j] == 0)
                    {
                        lookForEnd    = false;
                        segment.start = begin * scale;
                        segment.end   = i * scale;
                        pageSegs.Add(segment);
                    }
                    else if (i + 1 >= height)
                    {
                        segment.start = begin * scale;
                        segment.end   = -1;
                        pageSegs.Add(segment);
                    }
                    Console.WriteLine();
                }
                bookSegs.Add(pageSegs);
                maxSegCount = pageSegs.Count > maxSegCount ? pageSegs.Count : maxSegCount;
            }

            DataTable table = new DataTable();

            table.Columns.Add("Leaf/Page");
            for (int i = 0; i < maxSegCount; i++)
            {
                table.Columns.Add($"Cut {i + 1}");
            }
            var pageCount = 1;

            foreach (List <Segment> pageSegs in bookSegs)
            {
                var result = getLineForPageSegments(pageSegs, pageCount);
                table.Rows.Add(result);
                pageCount++;
            }

            PdfDocument   doc           = new PdfDocument();
            PdfPage       page          = doc.Pages.Add();
            PdfLightTable pdfLightTable = new PdfLightTable();

            pdfLightTable.Style.CellPadding = 3;
            pdfLightTable.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.GridTable3Accent3);
            pdfLightTable.DataSource       = table;
            pdfLightTable.Style.ShowHeader = true;
            pdfLightTable.Draw(page, new Syncfusion.Drawing.PointF(0, 0));

            var filePath = $"{rootPath}/temp{(new Random()).Next(0, 999)}.pdf";

            using (FileStream stream = new FileStream(filePath, FileMode.Create))
            {
                doc.Save(stream);
                doc.Close(true);
                stream.Close();
            }

            if (File.Exists(filePath))
            {
                var bytes = File.ReadAllBytes(filePath);
                File.Delete(filePath);
                return(Convert.ToBase64String(bytes));
            }
            return(null);
        }