Пример #1
0
        public MemoryStream GeneratePDF(Diploma_model diploma)
        {
            /*byte[] bytes = new byte[diploma.Name.Length * sizeof(char)];
             * System.Buffer.BlockCopy(diploma.Name.ToArray(), 0, bytes, 0, bytes.Length);
             * Encoding w1250 = Encoding.GetEncoding(1250);
             * Encoding utf8 = Encoding.GetEncoding("utf-8");
             * byte[] output = Encoding.Convert(utf8, w1250, utf8.GetBytes(diploma.Name));
             * diploma.Name = w1250.GetString(output);
             *
             * byte[] bytes1 = new byte[diploma.LastName.Length * sizeof(char)];
             * System.Buffer.BlockCopy(diploma.LastName.ToArray(), 0, bytes, 0, bytes.Length);
             * Encoding w12501 = Encoding.GetEncoding(1250);
             * Encoding utf81 = Encoding.GetEncoding("utf-8");
             * byte[] output1 = Encoding.Convert(utf81, w12501, utf81.GetBytes(diploma.LastName));
             * diploma.LastName = w1250.GetString(output1);*/

            using (MemoryStream stream = new MemoryStream())
                using (var writer = new PdfWriter(stream))
                {
                    //var writer = new PdfWriter(stream);
                    var pdf = new PdfDocument(writer);
                    //Fonts
                    PdfFont times_new_roman      = PdfFontFactory.CreateFont(StandardFonts.TIMES_ROMAN, iText.IO.Font.PdfEncodings.CP1257, true);
                    PdfFont times_new_roman_bold = PdfFontFactory.CreateFont(StandardFonts.TIMES_BOLD, iText.IO.Font.PdfEncodings.CP1257, true);
                    //Text Generic
                    Text rector         = new Text($"{diploma.RectorsName} {diploma.RectorsLastName} \nRektorius \nRector").SetFont(times_new_roman);
                    Text dateofissueLT  = new Text($"Išdavimo data:           {diploma.DateOfIssue.ToString("yyyy/MM/dd")}").SetFont(times_new_roman);
                    Text dateofissueENG = new Text($"Date of issue:          {diploma.DateOfIssue.ToString("dd/MMMM/yyyy")}").SetFont(times_new_roman);
                    //Text LT (fix it later)
                    Text namepart                  = new Text($"{diploma.Name.ToUpper()} {diploma.LastName.ToUpper()} ").SetFont(times_new_roman_bold);
                    Text identitypart              = new Text($"(asmens kodas {diploma.IdentityNumber})").SetFont(times_new_roman);
                    Text partBeforeprogramme       = new Text($"{diploma.DateOfIssue.Year} metais baigė bakalauro studijų programą ").SetFont(times_new_roman);
                    Text programmepart             = new Text($"{diploma.StudiesProgramme.ToUpper()} ").SetFont(times_new_roman_bold);
                    Text programmerGovermentIDCode = new Text($"(valstybinis kodas {diploma.StudiesProgrammeGovermentCode} )").SetFont(times_new_roman);
                    Text beforedegreepart          = new Text("ir jam suteiktas").SetFont(times_new_roman);
                    Text degreepart                = new Text($"{diploma.Degree.ToUpper()} ").SetFont(times_new_roman_bold);
                    Text afterdegreepart           = new Text("laipsnis").SetFont(times_new_roman);
                    Text studiesdirectionpart      = new Text($"Studijų kryptis - {diploma.Studiesdirection.ToUpper()}").SetFont(times_new_roman);
                    //Text Eng
                    Text identitypartENG = new Text($" (personal number/code {diploma.IdentityNumber})").SetFont(times_new_roman);
                    //Text degreeENG = new Text($"BACHELORS DEGREE OF {diploma.Degree.ToUpper()} ").SetFont(times_new_roman);
                    //Text studiesdirectionENG = new Text($"IN {diploma.Studiesdirection.ToUpper()} ").SetFont(times_new_roman);
                    Text degreeENG                    = new Text($"BACHELORS DEGREE OF INFORMATICS ENGINEERING ").SetFont(times_new_roman);
                    Text studiesdirectionENG          = new Text($"IN INFORMATICS ENGINEERING ").SetFont(times_new_roman);
                    Text partBeforeprogrammeENG       = new Text($"in {diploma.DateOfIssue.Year} completed bachelors study programme ").SetFont(times_new_roman);
                    Text programmepartENG             = new Text($"INFORMATION TECHNOLOGIES").SetFont(times_new_roman_bold);
                    Text programmerGovermentIDCodeENG = new Text($"(state code {diploma.StudiesProgrammeGovermentCode} )").SetFont(times_new_roman);
                    Text beforedegreepartENG          = new Text("and has been awarded").SetFont(times_new_roman);
                    //PDF construct
                    PageSize  pageSize = PageSize.A4.Rotate();
                    var       document = new Document(pdf, pageSize);
                    PdfCanvas canvas   = new PdfCanvas(pdf.AddNewPage());
                    canvas.AddImage(ImageDataFactory.Create(imageDestination), pageSize, false);
                    //document.Add(new Paragraph(diploma.LastName).SetFont(times_new_roman).SetFontSize(50).SetTextAlignment(TextAlignment.CENTER));
                    //document.Add(new Paragraph($"{diploma.Name.ToUpper()} {diploma.LastName.ToUpper()} (asmens kodas {diploma.IdentityNumber})").SetFont(times_new_roman).SetFontSize(16).SetTextAlignment(TextAlignment.CENTER));
                    //Text spacing (fix it later)
                    document.Add(new Paragraph("\n \n \n").SetFont(times_new_roman).SetFontSize(50).SetTextAlignment(TextAlignment.CENTER).SetMultipliedLeading(1.0f));
                    document.Add(new Paragraph("\n \n").SetFont(times_new_roman).SetFontSize(25).SetTextAlignment(TextAlignment.CENTER).SetMultipliedLeading(1.0f));
                    document.Add(new Paragraph("\n").SetFont(times_new_roman).SetFontSize(15).SetTextAlignment(TextAlignment.CENTER).SetMultipliedLeading(1.0f));
                    document.SetProperty(Property.LEADING, new Leading(Leading.MULTIPLIED, 0.5f));
                    //Text construct LT part
                    document.Add(new Paragraph().Add(namepart).Add(identitypart).SetTextAlignment(TextAlignment.CENTER));
                    document.Add(new Paragraph().Add(partBeforeprogramme).Add(programmepart).Add(programmerGovermentIDCode).SetTextAlignment(TextAlignment.CENTER));
                    document.Add(new Paragraph().Add(beforedegreepart).SetTextAlignment(TextAlignment.CENTER));
                    document.Add(new Paragraph().Add(degreepart).Add(afterdegreepart).SetTextAlignment(TextAlignment.CENTER));
                    document.Add(new Paragraph().Add(studiesdirectionpart).SetTextAlignment(TextAlignment.CENTER));
                    document.Add(new Paragraph("\n").SetTextAlignment(TextAlignment.CENTER));
                    //Text construct ENG part
                    document.Add(new Paragraph().Add(namepart).Add(identitypartENG).SetTextAlignment(TextAlignment.CENTER));
                    document.Add(new Paragraph().Add(partBeforeprogrammeENG).Add(programmepartENG).Add(programmerGovermentIDCodeENG).SetTextAlignment(TextAlignment.CENTER));
                    document.Add(new Paragraph().Add(beforedegreepartENG).SetTextAlignment(TextAlignment.CENTER));
                    document.Add(new Paragraph().Add(degreeENG).SetTextAlignment(TextAlignment.CENTER));
                    document.Add(new Paragraph().Add(studiesdirectionENG).SetTextAlignment(TextAlignment.CENTER));
                    //Rector part
                    document.Add(new Paragraph().Add(rector).SetFontSize(11).SetTextAlignment(TextAlignment.LEFT).SetMultipliedLeading(1.0f));
                    //metadata part
                    //document.Add(new Paragraph().Add(dateofissueLT).SetFontSize(10).SetTextAlignment(TextAlignment.RIGHT).SetMultipliedLeading(0.8f));
                    //document.Add(new Paragraph().Add(dateofissueENG).SetFontSize(10).SetTextAlignment(TextAlignment.RIGHT).SetMultipliedLeading(0.8f));
                    Table table = new Table(2, true);
                    Style style = new Style().SetBorder(Border.NO_BORDER);
                    table.SetWidth(200);
                    table.SetHorizontalAlignment(HorizontalAlignment.RIGHT);
                    //table.AddCell(new Cell("Išdavimo data:").SetTextAlignment(TextAlignment.LEFT)).AddStyle(style);
                    //https://itextpdf.com/en/resources/faq/technical-support/itext-7/why-doesnt-getdefaultcellsetborderpdfpcellnoborder-have-any
                    //https://kodejava.org/how-do-i-create-table-cell-that-span-multiple-columns-in-itext/
                    table.AddCell(new Paragraph("Registracijos Nr").SetTextAlignment(TextAlignment.LEFT));
                    table.AddCell(new Paragraph($"{diploma.RegistrationNr}").SetTextAlignment(TextAlignment.LEFT));
                    table.AddCell(new Paragraph("Registracijos Nr").SetTextAlignment(TextAlignment.LEFT));
                    table.AddCell(new Paragraph("").SetTextAlignment(TextAlignment.LEFT));
                    table.AddCell(new Paragraph("Išdavimo data:").SetTextAlignment(TextAlignment.LEFT));
                    table.AddCell(new Paragraph(diploma.DateOfIssue.ToString("yyyy/MM/dd")).SetTextAlignment(TextAlignment.LEFT));
                    table.AddCell(new Paragraph("Date of sssue:").SetTextAlignment(TextAlignment.LEFT));
                    table.AddCell(new Paragraph(diploma.DateOfIssue.ToString("dd/MMMM/yyyy")).SetTextAlignment(TextAlignment.LEFT));
                    table.AddCell(new Paragraph("Code in system:").SetTextAlignment(TextAlignment.LEFT));
                    table.AddCell(new Paragraph(diploma.quickSearch.ToString()).SetTextAlignment(TextAlignment.LEFT));
                    document.Add(table);
                    document.Close();
                    writer.Close();
                    return(stream);
                }
            //var stream = new MemoryStream();
        }
Пример #2
0
        private void BuildPDF()
        {
            try
            {
                // step 1: creation of a document-object
                document = new Document(PageSize.A4);

                // step 2: we create a writer that listens to the document
                PdfWriter.GetInstance(document, new FileStream(sFilePDF, FileMode.Create));

                document.Open();

                PDFGen pdfgen = new PDFGen();

                Image img0 = pdfgen.DoGetImageFile(_resourcePath + "kra2.jpg");
                img0.Alignment = Image.ALIGN_LEFT;

                Table empInfoTable = new Table(1);
                empInfoTable.WidthPercentage = 100;
                empInfoTable.Border          = Table.NO_BORDER;

                Phrase header1 = new Phrase(_ViewModel.ReportName, hFont2);
                Cell   c2      = new Cell(header1);
                c2.Border = Cell.NO_BORDER;
                c2.HorizontalAlignment = Cell.ALIGN_CENTER;
                // c1.Colspan = 3;
                empInfoTable.AddCell(c2, new System.Drawing.Point(1, 0));

                Cell c1 = new Cell(img0);// header1);
                c1.Border = Cell.NO_BORDER;
                c1.HorizontalAlignment = Cell.ALIGN_CENTER;
                // c1.Colspan = 3;

                empInfoTable.AddCell(c1, new System.Drawing.Point(0, 0));

                Chunk name     = new Chunk("P.A.Y.E SUPPORTING LIST FOR END OF YEAR CERTIFICATE: YEAR.." + _ViewModel.Year.ToString() + "..", bFont2);
                Cell  emp2Cell = new Cell(name);
                emp2Cell.Border = Cell.NO_BORDER;
                empInfoTable.AddCell(emp2Cell, new System.Drawing.Point(2, 0));

                Chunk formname = new Chunk("P10A", bFont1);
                Cell  emp1Cell = new Cell(formname);
                emp1Cell.Border = Cell.NO_BORDER;
                emp1Cell.HorizontalAlignment = Cell.ALIGN_LEFT;
                empInfoTable.AddCell(emp1Cell, new System.Drawing.Point(3, 0));

                Chunk employerName = new Chunk("Employer's Name ..." + _ViewModel.EmployerName.ToUpper().Trim() + "..........                                                   Employer's PIN ..." + _ViewModel.EmployerPin.Trim() + "..", bFont1);
                Cell  empCell      = new Cell(employerName);
                empCell.Border = Cell.NO_BORDER;
                empInfoTable.AddCell(empCell, new System.Drawing.Point(4, 0));

                document.Add(empInfoTable);
                document.Add(new Phrase("", new Font(Font.TIMES_ROMAN, 2, Font.NORMAL)));

                Table taxTable = new Table(4);
                taxTable.Padding         = 1;
                taxTable.Spacing         = 1;
                taxTable.WidthPercentage = 100;

                //Add table headers
                AddTableHeaders(taxTable);

                //Add table details
                foreach (var tr in _ViewModel.P10AList)
                {
                    AddTableRow(taxTable, tr);
                }

                //Add totals
                AddTotals(taxTable);

                document.Add(taxTable);

                AddFooter();

                document.Close();
            }
            catch (DocumentException de)
            {
                this.Message = de.Message;
            }
            catch (IOException ioe)
            {
                this.Message = ioe.Message;
            }
            catch (Exception ex)
            {
                Log.WriteToErrorLogFile(ex);
            }
        }
Пример #3
0
        private static Table GetMonthTable(ThunderPrinter tp, Calendar calendar, DateTime month)
        {
            var   day = month;
            float topM, rowH;

            if (month.DayOfWeek == DayOfWeek.Monday)
            {
                topM = 0;
                var c    = month.AddMonths(1).AddDays(-1).Day - day.Day + 1;
                var rows = Math.Ceiling(Convert.ToSingle(c) / 7);
                rowH = Convert.ToSingle(490f / rows);
            }
            else
            {
                topM = -20f;
                while (day.DayOfWeek != DayOfWeek.Monday)
                {
                    day = day.AddDays(1);
                }
                var c    = month.AddMonths(1).AddDays(-1).Day - day.Day + 1;
                var rows = Math.Ceiling(Convert.ToSingle(c) / 7) + 1;
                rowH = Convert.ToSingle(510f / rows);
            }

            var table = new Table(new float[] { 1, 1, 1, 1, 1, 1, 1 })
                        .SetFixedLayout()
                        .SetWidthPercent(100)
                        .SetMarginTop(topM);

            day = month;
            while (day.DayOfWeek != DayOfWeek.Monday)
            {
                day = day.AddDays(-1);
            }
            table.StartNewRow();
            while (day.Month != month.Month)
            {
                table.AddCell(new Cell()
                              .SetHeight(rowH).SetBorder(Border.NO_BORDER));
                day = day.AddDays(1);
            }

            var allDays = new List <Occurrence>();
            var today   = DateTime.Now.Date;

            while (day.Month == month.Month)
            {
                if (day.DayOfWeek == DayOfWeek.Monday && day.Day != 1)
                {
                    table.StartNewRow();
                    allDays = new List <Occurrence>();
                }

                var cell = new Cell()
                           .SetHeight(rowH)
                           .Add(new Paragraph(day.Day.ToString("00"))
                                .SetMarginLeft(-1).SetMarginTop(-2).SetBold())
                           .SetFont(Font1).SetFontSize(7)
                           .SetWidthPercent(100);

                if (day < today)
                {
                    cell.SetNextRenderer(new StrikedCellRenderer(cell));
                }

                if (day.DayOfWeek == DayOfWeek.Saturday || day.DayOfWeek == DayOfWeek.Sunday)
                {
                    cell.SetBackgroundColor(Color1);
                }

                // this works but
                // still, cannot position another cell at bottom?
                var ctable = new Table(new float[] { 1 }).SetWidthPercent(100);
                ctable.StartNewRow();

                var occurences = tp.GetDayOccurences(calendar, day).ToList();

                /*
                 * foreach (var o in occurences)
                 * {
                 *  var e = (Event) o.Source;
                 *  if (!e.Name.StartsWith("Plong")) continue;
                 *  Console.WriteLine("{0} {1}", e.Name, e.Summary);
                 *  Console.WriteLine("  {0} - {1}", e.Start, e.End);
                 *  Console.WriteLine("  ri: {0}", e.RecurrenceId);
                 *  Console.WriteLine("  xd: {0}", e.ExceptionDates.Count);
                 *  foreach (var ed in e.ExceptionDates)
                 *  {
                 *      Console.WriteLine("   -    {0}", ed.TzId);
                 *      foreach (var p in ed)
                 *      {
                 *          Console.WriteLine("    -    {0} - {1}", p.StartTime, p.EndTime);
                 *      }
                 *  }
                 *  Console.WriteLine("  xr: {0}", e.ExceptionRules.Count);
                 * }
                 */

                var allDays2 = new List <Occurrence>();
                foreach (var occurrence in occurences) // gather today's all-day events
                {
                    var e = occurrence.GetEvent();
                    if (!e.IsAllDay)
                    {
                        continue;
                    }
                    allDays2.Add(occurrence);
                }
                for (var i = 0; i < allDays.Count; i++) // clear know all-day events (remove those that are gone)
                {
                    var o = allDays[i];
                    if (o == null)
                    {
                        continue;
                    }
                    var e = o.GetEvent();
                    if (allDays2.All(x => x.GetEvent().Uid != e.Uid))
                    {
                        allDays[i] = null;
                    }
                }
                for (var i = allDays.Count - 1; i >= 0; i--) // truncate the list (remove trailing nulls)
                {
                    if (allDays[i] != null)
                    {
                        break;
                    }
                    allDays.RemoveAt(i);
                }
                var adc = 0;
                foreach (var o in allDays2) // add new all-day events
                {
                    var oUid = o.GetEvent().Uid;
                    var i    = 0;
                    while (i < allDays.Count)
                    {
                        if (allDays[i] != null && allDays[i].GetEvent().Uid == oUid)
                        {
                            break;
                        }
                        i++;
                    }
                    if (i < allDays.Count)
                    {
                        allDays[i] = o;
                        continue;
                    }
                    while (adc < allDays.Count && allDays[adc] != null)
                    {
                        adc++;
                    }
                    if (adc == allDays.Count)
                    {
                        allDays.Add(o);
                    }
                    else
                    {
                        allDays[adc] = o;
                    }
                }

                var ccell = new Cell().SetBorder(Border.NO_BORDER).SetWidthPercent(100);
                var top   = 0;

                foreach (var o in allDays)
                {
                    if (o == null)
                    {
                        ccell.Add(new Paragraph("-")
                                  .SetFontColor(Color3)
                                  .SetMarginTop(0).SetMarginBottom(1).SetPaddingTop(-2).SetPaddingBottom(-1));
                    }
                    else
                    {
                        TextAlignment align;
                        var           prefix  = string.Empty;
                        var           postfix = string.Empty;
                        if (o.Period.EndTime.Date == day.Date.AddDays(1))
                        {
                            align = TextAlignment.RIGHT;
                            if (o.Period.Duration > TimeSpan.FromDays(1))
                            {
                                postfix = " ]";
                            }
                        }
                        else if (o.Period.StartTime.Date == day.Date)
                        {
                            align = TextAlignment.LEFT;
                            if (o.Period.Duration > TimeSpan.FromDays(1))
                            {
                                prefix = "[ ";
                            }
                        }
                        else
                        {
                            align = TextAlignment.CENTER;
                        }

                        var e = o.GetEvent();

                        var para = new Paragraph()
                                   .SetWidthPercent(100).SetTextAlignment(align).SetBackgroundColor(Color2)
                                   .SetMarginTop(0).SetMarginBottom(1).SetPaddingTop(-2).SetPaddingBottom(-1)
                                   .SetPaddingLeft(1).SetPaddingRight(1);
                        if (prefix != string.Empty)
                        {
                            para.Add(new Text(prefix));
                        }
                        para.Add(new Text(e.Name).SetItalic());
                        if (postfix != string.Empty)
                        {
                            para.Add(new Text(postfix));
                        }

                        ccell
                        .SetWidthPercent(100)
                        .Add(para);
                    }
                    top = 5; // we have at least 1 all days event
                }

                foreach (var occurrence in occurences)
                {
                    var e = occurrence.GetEvent();

                    var calendarName = e.Properties["CALNAME"].Value.ToString();

                    if (e.IsAllDay)
                    {
                        continue;
                    }

                    if (calendarName == "Tasks")
                    {
                        ccell.Add(new Paragraph($"{occurrence.Period.StartTime.AsUtc:t} {e.Name}")
                                  .SetFirstLineIndent(-5).SetMultipliedLeading(.9f)
                                  .SetMarginLeft(5).SetMarginTop(top).SetMarginBottom(0).SetPaddingTop(0).SetPaddingBottom(0));
                    }
                    else
                    {
                        ccell.Add(new Paragraph($"{occurrence.Period.StartTime.AsUtc:t}-{occurrence.Period.EndTime.AsUtc:t} {e.Name}")
                                  .SetFirstLineIndent(-5).SetMultipliedLeading(.9f)
                                  .SetMarginLeft(5).SetMarginTop(top).SetMarginBottom(0).SetPaddingTop(0).SetPaddingBottom(0));
                    }

                    top = 0;
                }

                ctable.AddCell(ccell);
                cell.Add(ctable);

                table.AddCell(cell);
                day = day.AddDays(1);
            }

            while (day.DayOfWeek != DayOfWeek.Monday)
            {
                table.AddCell(new Cell()
                              .SetHeight(rowH).SetBorder(Border.NO_BORDER));
                day = day.AddDays(1);
            }

            return(table);
        }
        private void AddTableBody()
        {
            //
            Table payeeTable = new Table(4);

            payeeTable.WidthPercentage = 100;
            payeeTable.Padding         = 2;
            payeeTable.Spacing         = 1;

            //Add table headers
            Cell cell = new Cell(new Phrase("No", tHFont));

            cell.HorizontalAlignment = Cell.ALIGN_CENTER;
            payeeTable.AddCell(cell);

            Cell nameTCell = new Cell(new Phrase("Name", tHFont));

            nameTCell.HorizontalAlignment = Cell.ALIGN_CENTER;
            payeeTable.AddCell(nameTCell);

            Cell idTCell = new Cell(new Phrase("Pin No", tHFont));

            idTCell.HorizontalAlignment = Cell.ALIGN_CENTER;
            payeeTable.AddCell(idTCell);

            Cell amtCell = new Cell(new Phrase("PAYE Tax\nKshs", tHFont));

            amtCell.HorizontalAlignment = Cell.ALIGN_CENTER;
            payeeTable.AddCell(amtCell);

            //add table details
            foreach (var pay in _ViewModel.PAYEItemList)
            {
                Cell empnocell = new Cell(new Phrase(pay.EmpNo, tcFont));
                empnocell.HorizontalAlignment = Cell.ALIGN_LEFT;
                payeeTable.AddCell(empnocell);

                Cell nameCell = new Cell(new Phrase(pay.Surname.Trim() + ",  " + pay.OtherNames.Trim(), tcFont));
                nameCell.HorizontalAlignment = Cell.ALIGN_LEFT;
                payeeTable.AddCell(nameCell);

                Cell pinCell = new Cell(new Phrase(pay.PINNo, tcFont));
                pinCell.HorizontalAlignment = Cell.ALIGN_LEFT;
                payeeTable.AddCell(pinCell);

                Cell taxCell = new Cell(new Phrase(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:N0}", pay.PayeTax), tcFont));
                taxCell.HorizontalAlignment = Cell.ALIGN_RIGHT;
                payeeTable.AddCell(taxCell);
            }

            Cell totalCell = new Cell(new Phrase("TOTAL PAYMENTS", tcFont1));

            totalCell.HorizontalAlignment = Cell.ALIGN_LEFT;
            totalCell.Colspan             = 3;
            payeeTable.AddCell(totalCell);

            Cell totalvalueCell = new Cell(new Phrase(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:N0}", _ViewModel.TotalPAYE), tcFont1));

            totalvalueCell.HorizontalAlignment = Cell.ALIGN_RIGHT;
            payeeTable.AddCell(totalvalueCell);

            Cell totalItemsCell = new Cell(new Phrase("TOTAL ITEMS", tcFont1));

            totalItemsCell.HorizontalAlignment = Cell.ALIGN_LEFT;
            totalItemsCell.Colspan             = 3;
            payeeTable.AddCell(totalItemsCell);

            Cell countCell = new Cell(new Phrase(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:N0}", _ViewModel.TotalItems), tcFont1));

            countCell.HorizontalAlignment = Cell.ALIGN_RIGHT;
            payeeTable.AddCell(countCell);

            document.Add(payeeTable);
        }
        private void CrearPDF()
        {
            PdfWriter   pdfWriter = new PdfWriter("Reporte.pdf");
            PdfDocument pdf       = new PdfDocument(pdfWriter);
            Document    document  = new Document(pdf, PageSize.LETTER);

            document.SetMargins(60, 20, 55, 20);
            //var parrafo = new Paragraph("Hola mundo");
            //document.Add(parrafo);

            PdfFont fontColumnas  = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD);
            PdfFont fontContenido = PdfFontFactory.CreateFont(StandardFonts.HELVETICA);

            string[] columnas = { "Numero de ingreso", "Usuario", "Fecha y Hora" };//Id_Bitacora,Id_Usr,HORA
            float[]  tamanos  = { 4, 4, 4 };
            Table    tabla    = new Table(UnitValue.CreatePercentArray(tamanos));

            tabla.SetWidth(UnitValue.CreatePercentValue(100));
            foreach (string columna in columnas)
            {
                tabla.AddHeaderCell(new Cell().Add(new Paragraph(columna).SetFont(fontColumnas)));
            }
            string sql = "SELECT p.Id_Bitacora,p.Id_Usuario,p.HORA FROM bitacora AS p ";

            cn.Open();
            MySqlCommand    comando = new MySqlCommand(sql, cn);
            MySqlDataReader reader  = comando.ExecuteReader();

            while (reader.Read())
            {
                //for(int x = 1; x < 100; x++) {
                tabla.AddCell(new Cell().Add(new Paragraph(reader["Id_Bitacora"].ToString()).SetFont(fontContenido)));
                tabla.AddCell(new Cell().Add(new Paragraph(reader["Id_Usuario"].ToString()).SetFont(fontContenido)));
                tabla.AddCell(new Cell().Add(new Paragraph(reader["HORA"].ToString()).SetFont(fontContenido)));
                //}
            }
            document.Add(tabla);
            document.Close();
            var logo   = new iText.Layout.Element.Image(ImageDataFactory.Create("logo.png")).SetWidth(50);
            var plogo  = new Paragraph("").Add(logo);
            var titulo = new Paragraph("Reporte de ingresos al sistema");

            titulo.SetTextAlignment(TextAlignment.CENTER);
            titulo.SetFontSize(14);
            var dfecha = DateTime.Now.ToString("dd-MM-yyyy");
            var dhora  = DateTime.Now.ToString("hh:mm:ss");
            var fecha  = new Paragraph("Fecha: " + dfecha + " Hora: " + dhora);

            fecha.SetFontSize(8);
            PdfDocument pdfDoc  = new PdfDocument(new PdfReader("Reporte.pdf"), new PdfWriter("Reportefechado.pdf"));
            Document    doc     = new Document(pdfDoc);
            int         numeros = pdfDoc.GetNumberOfPages();

            for (int i = 1; i <= numeros; i++)
            {
                PdfPage pagina = pdfDoc.GetPage(i);
                float   y      = (pdfDoc.GetPage(i).GetPageSize().GetTop() - 15);
                doc.ShowTextAligned(plogo, 40, y, i, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
                doc.ShowTextAligned(titulo, 150, y, i, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
                doc.ShowTextAligned(fecha, 520, y, i, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
                doc.ShowTextAligned(new Paragraph(String.Format("Página {0} de {1}", i, numeros)), pdfDoc.GetPage(i).GetPageSize().GetWidth() / 2, pdfDoc.GetPage(i).GetPageSize().GetBottom() + 30, i, TextAlignment.CENTER, VerticalAlignment.TOP, 0);
            }
            doc.Close();
        }
Пример #6
0
        public void TotalVentasMesArticulo(DataTable dt)
        {
            FileInfo file = new FileInfo(DEST);

            file.Directory.Create();

            string      dest   = "c:/temp/ReporteMesArticulo1.pdf";
            PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest,
                                                               new WriterProperties().AddUAXmpMetadata().SetPdfVersion
                                                                   (PdfVersion.PDF_1_7)));
            Document document = new Document(pdfDoc, PageSize.LETTER.Rotate());

            //PDF/UA
            //Set document metadata
            pdfDoc.GetCatalog().SetViewerPreferences(new PdfViewerPreferences().SetDisplayDocTitle(true));
            pdfDoc.GetCatalog().SetLang(new PdfString("en-US"));
            PdfDocumentInfo info = pdfDoc.GetDocumentInfo();

            info.SetTitle("Reporte de Ventas de Artículo por Mes");

            float[] columnWidths = { 1, 5, 2 };
            Table   tabla        = new Table(UnitValue.CreatePercentArray(columnWidths));

            //tabla.SetWidth();
            tabla.UseAllAvailableWidth();
            PdfFont font = PdfFontFactory.CreateFont(StandardFonts.HELVETICA);
            // celda de encabezado

            Text txt = new Text("Reporte de Ventas Semanal")
                       .SetFontSize(20)
                       .SetBold();

            Paragraph pTitulo = new Paragraph(txt)
                                .SetTextAlignment(TextAlignment.CENTER);

            document.Add(pTitulo);

            for (int i = 0; i < 2; i++)
            {
                Cell[] headerFooter =
                {
                    new Cell()
                    .SetBackgroundColor(new DeviceGray(0.75f))
                    .Add(new Paragraph("Mes"))
                    .SetBorder(Border.NO_BORDER),
                    new Cell()
                    .SetBackgroundColor(new DeviceGray(0.75f))
                    .Add(new Paragraph("Artículo"))
                    .SetBorder(Border.NO_BORDER),
                    new Cell()
                    .SetBackgroundColor(new DeviceGray(0.75f))
                    .Add(new Paragraph("Total"))
                    .SetBorder(Border.NO_BORDER)
                };

                foreach (Cell hfCell in headerFooter)
                {
                    if (i == 0)
                    {
                        tabla.AddHeaderCell(hfCell);
                    }
                }
            }

            decimal totalMes = 0;

            Cell c_mes      = new Cell().SetTextAlignment(TextAlignment.CENTER);
            Cell c_articulo = new Cell().SetTextAlignment(TextAlignment.LEFT);
            Cell c_total    = new Cell().SetTextAlignment(TextAlignment.RIGHT);

            tabla.AddCell(c_articulo);
            tabla.AddCell(c_mes);
            tabla.AddCell(c_total);

            // ciclo para filas
            for (int j = 0; j < dt.Rows.Count; j++)
            {
                c_mes.Add(new Paragraph(dt.Rows[j][0].ToString()));
                c_articulo.Add(new Paragraph(dt.Rows[j][1].ToString()));
                c_total.Add(new Paragraph(dt.Rows[j][2].ToString()));

                totalMes += (decimal)dt.Rows[j][2];
            }

            document.Add(tabla);
            Paragraph p = new Paragraph();

            p.SetTextAlignment(TextAlignment.RIGHT);
            p.Add("Total del mes: $" + totalMes);

            document.Add(p);

            document.Close();
        }
Пример #7
0
        public static void PageFonts(Document pdf, PdfWriter writer)
        {
            // FONTS
            var title = new Paragraph("Fonts standard", new Font(Font.HELVETICA, 20, Font.BOLD));

            pdf.Add(title);


            // --- TIMES ROMAN
            title = new Paragraph("Times Roman")
            {
                SpacingBefore = 18f,
                SpacingAfter  = 9f
            };
            pdf.Add(title);


            BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, encoding: BaseFont.CP1252, embedded: false);

            Pattern(pdf, bfTimes);


            // --- COURIER
            title = new Paragraph("Courier")
            {
                SpacingBefore = 18f,
                SpacingAfter  = 9f
            };
            pdf.Add(title);

            BaseFont bfCourier = BaseFont.CreateFont(BaseFont.COURIER, encoding: BaseFont.CP1252, embedded: false);

            Pattern(pdf, bfCourier);


            // --- HELVETICA
            title = new Paragraph("Helvetica")
            {
                SpacingBefore = 18f,
                SpacingAfter  = 9f
            };
            pdf.Add(title);

            BaseFont bfHelvetica = BaseFont.CreateFont(BaseFont.HELVETICA, encoding: BaseFont.CP1252, embedded: false);

            Pattern(pdf, bfHelvetica);


            // --- SYMBOL
            title = new Paragraph("Symbol")
            {
                SpacingBefore = 18f,
                SpacingAfter  = 9f
            };
            pdf.Add(title);

            BaseFont bSymbol = BaseFont.CreateFont(BaseFont.SYMBOL, encoding: BaseFont.CP1252, embedded: false);

            Pattern(pdf, bSymbol);


            // --- ZAPDINGBATS
            title = new Paragraph("ZapfDingBats®")
            {
                SpacingBefore = 18f,
                SpacingAfter  = 9f
            };
            pdf.Add(title);

            BaseFont bZapfDingBats = BaseFont.CreateFont(BaseFont.ZAPFDINGBATS, encoding: BaseFont.CP1252, embedded: false);

            Pattern(pdf, bZapfDingBats);


            // BREAK RETURN : so easy ^^
            pdf.NewPage();


            // FONTS  EMBEDDED INTO THE PDF
            title = new Paragraph("Font embedded", new Font(Font.HELVETICA, 20, Font.BOLD));
            pdf.Add(title);

            BaseFont myfont = BaseFont.CreateFont(@"Assets/Moder DOS 437.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
            Font     font   = new Font(myfont, 14);

            string s = "Add your own font in your document as here the Moder DOS";

            pdf.Add(new Paragraph(s, font));


            Table datatable = new Table(16);

            datatable.Padding = 2;
            datatable.Spacing = 0;
            datatable.Border  = 0;
            float[] headerwidths = Enumerable.Range(0, 16).Select(i => 1.6f).ToArray();
            datatable.Widths = headerwidths;
            datatable.DefaultHorizontalAlignment = Element.ALIGN_CENTER;

            int    m = 9;
            string charater;

            for (int r = 0; r < 16; r++)
            {
                for (int c = 0; c < 16; c++)
                {
                    if (m > 31)
                    {
                        charater = Convert.ToChar(m).ToString();
                        datatable.AddCell(new Paragraph(charater, font));
                    }
                    m++;
                }
            }
            pdf.Add(datatable);
        }
        private Table consultasobrante()
        {
            //estilo titulo tabla
            Style   titulo = new Style();
            PdfFont f      = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLDOBLIQUE);

            titulo.SetFont(f).SetFontSize(16).SetTextAlignment(TextAlignment.CENTER);

            //estilo encabezado
            Style   encabezado = new Style();
            PdfFont f1         = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD);

            encabezado.SetFont(f1).SetFontSize(12).SetTextAlignment(TextAlignment.LEFT);

            //estilo cuerpo general
            Style   cuerpogeneral = new Style();
            PdfFont f2            = PdfFontFactory.CreateFont(StandardFonts.HELVETICA);

            cuerpogeneral.SetFont(f2).SetFontSize(12).SetTextAlignment(TextAlignment.LEFT);

            //creacion de la tabla
            Table table = new Table(new float[7]).UseAllAvailableWidth();

            table.SetMarginTop(0);
            table.SetMarginBottom(0);
            Cell cell = new Cell(1, 7);

            cell.Add(new Paragraph("Reporte de materiales sobrantes"));

            cell.AddStyle(titulo);
            cell.SetTextAlignment(TextAlignment.CENTER);
            cell.SetPadding(3);
            cell.SetBackgroundColor(new DeviceRgb(140, 221, 8));
            table.AddCell(cell);

            table.AddCell("Material").AddStyle(encabezado);
            table.AddCell("Cantidad en existencia").AddStyle(encabezado);
            table.AddCell("Cantidad para alerta").AddStyle(encabezado);
            table.AddCell("Cantidad usada en speed").AddStyle(encabezado);
            table.AddCell("Cantidad usada en flex").AddStyle(encabezado);
            table.AddCell("Cantidad usada en 360").AddStyle(encabezado);
            table.AddCell("Usuario que registro").AddStyle(encabezado);

            string Query = "SELECT nombre,cantidad_inicial,stock_alert,cant_speed,cant_flex,cant_360,usuario FROM inventarioprograma.materialusario;";

            MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
            var             cmd     = new MySqlCommand(Query, MyConn2);

            MyConn2.Open();
            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                table.AddCell(new Paragraph(rdr.GetString(0)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(1)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(2)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(3)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(4)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(5)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(6)).AddStyle(cuerpogeneral));
            }
            MyConn2.Close();
            return(table);
        }
        private Table consultamaterial(int valor)
        {
            //estilo titulo tabla
            Style   titulo = new Style();
            PdfFont f      = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLDOBLIQUE);

            titulo.SetFont(f).SetFontSize(16).SetTextAlignment(TextAlignment.CENTER);

            //estilo encabezado
            Style   encabezado = new Style();
            PdfFont f1         = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD);

            encabezado.SetFont(f1).SetFontSize(12).SetTextAlignment(TextAlignment.LEFT);

            //estilo cuerpo general
            Style   cuerpogeneral = new Style();
            PdfFont f2            = PdfFontFactory.CreateFont(StandardFonts.HELVETICA);

            cuerpogeneral.SetFont(f2).SetFontSize(12).SetTextAlignment(TextAlignment.LEFT);

            //estilo totales
            Style   cuerpototal = new Style();
            PdfFont f3          = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD);

            cuerpototal.SetFont(f3).SetFontSize(12).SetTextAlignment(TextAlignment.LEFT);

            //creacion de la tabla
            Table table = new Table(new float[9]).UseAllAvailableWidth();

            table.SetMarginTop(0);
            table.SetMarginBottom(0);
            Cell cell = new Cell(1, 9);

            // first row
            if (valor == 1)
            {
                cell.Add(new Paragraph("Reporte del dia " + DateTime.Now.ToShortDateString()));
            }
            else if (valor == 2)
            {
                cell.Add(new Paragraph("Reporte del Mes de " + CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Month)));
            }
            else
            {
                cell.Add(new Paragraph("Reporte del año " + DateTime.Now.Year.ToString()));
            }

            cell.AddStyle(titulo);
            cell.SetTextAlignment(TextAlignment.CENTER);
            cell.SetPadding(3);
            cell.SetBackgroundColor(new DeviceRgb(140, 221, 8));
            table.AddCell(cell);

            table.AddCell("Material").AddStyle(encabezado);
            table.AddCell("Producccion en flex").AddStyle(encabezado);
            table.AddCell("Produccion en Speed").AddStyle(encabezado);
            table.AddCell("Produccion en 360").AddStyle(encabezado);
            table.AddCell("Usado en flex").AddStyle(encabezado);
            table.AddCell("Usado en speed").AddStyle(encabezado);
            table.AddCell("Usado en 360").AddStyle(encabezado);
            table.AddCell("Fecha de registro").AddStyle(encabezado);
            table.AddCell("Registrado por").AddStyle(encabezado);

            int    anio = DateTime.Now.Year;
            string mes;

            if (DateTime.Now.Month < 10)
            {
                mes = "0" + DateTime.Now.Month.ToString();
            }
            else
            {
                mes = DateTime.Now.Month.ToString();
            }
            int    dia = DateTime.Now.Day;
            string Query, Query2;

            //del dia
            if (valor == 1)
            {
                Query  = "SELECT nombre,prod_flex,prod_speed,prod_360,material_flex,material_speed,material_360,fecha_produccion,usuario FROM inventarioprograma.materialregistro where fecha_produccion >= ('" + anio + "-" + mes + "-" + dia + " 00:00:00') and fecha_produccion < ('" + anio + "-" + mes + "-" + (dia + 1) + " 00:00:00') order by fecha_produccion";
                Query2 = "SELECT nombre,sum(prod_flex),sum(prod_speed),sum(prod_360),sum(material_flex),sum(material_speed),sum(material_360) FROM inventarioprograma.materialregistro where fecha_produccion >= ('" + anio + "-" + mes + "-" + dia + " 00:00:00') and fecha_produccion < ('" + anio + "-" + mes + "-" + (dia + 1) + " 00:00:00') group by nombre;";
            }
            //del mes
            else if (valor == 2)
            {
                Query  = "SELECT nombre,prod_flex,prod_speed,prod_360,material_flex,material_speed,material_360,fecha_produccion,usuario FROM inventarioprograma.materialregistro where fecha_produccion like ('" + anio + "-" + mes + "%') order by fecha_produccion";
                Query2 = "SELECT nombre,sum(prod_flex),sum(prod_speed),sum(prod_360),sum(material_flex),sum(material_speed),sum(material_360) FROM inventarioprograma.materialregistro where fecha_produccion like ('" + anio + "-" + mes + "%') group by nombre;";
            }
            //anual
            else
            {
                Query  = "SELECT nombre,prod_flex,prod_speed,prod_360,material_flex,material_speed,material_360,fecha_produccion,usuario FROM inventarioprograma.materialregistro where fecha_produccion like ('" + DateTime.Now.Year + "%') order by fecha_produccion";
                Query2 = "SELECT nombre,sum(prod_flex),sum(prod_speed),sum(prod_360),sum(material_flex),sum(material_speed),sum(material_360) FROM inventarioprograma.materialregistro where fecha_produccion like ('" + DateTime.Now.Year + "%') group by nombre;";
            }

            MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
            var             cmd     = new MySqlCommand(Query, MyConn2);

            MyConn2.Open();
            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                table.AddCell(new Paragraph(rdr.GetString(0)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(1)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(2)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(3)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(4)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(5)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(6)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(7)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(8)).AddStyle(cuerpogeneral));
            }
            MyConn2.Close();

            cell.AddStyle(cuerpototal);
            //totales
            var cmd2 = new MySqlCommand(Query2, MyConn2);

            MyConn2.Open();
            MySqlDataReader rdr2 = cmd2.ExecuteReader();

            while (rdr2.Read())
            {
                table.AddCell(new Paragraph(rdr2.GetString(0)));
                table.AddCell(new Paragraph(rdr2.GetString(1)));
                table.AddCell(new Paragraph(rdr2.GetString(2)));
                table.AddCell(new Paragraph(rdr2.GetString(3)));
                table.AddCell(new Paragraph(rdr2.GetString(4)));
                table.AddCell(new Paragraph(rdr2.GetString(5)));
                table.AddCell(new Paragraph(rdr2.GetString(6)));
                table.AddCell(new Paragraph("----------"));
                table.AddCell(new Paragraph("----------"));
            }
            MyConn2.Close();

            return(table);
        }
Пример #10
0
        public static void Export(string filename, Invoice invoice)
        {
            try
            {
                System.IO.Directory.CreateDirectory(@"c:\temp\");

                PdfWriter   writer   = new PdfWriter(@"c:\temp\" + filename + ".pdf");
                PdfDocument pdf      = new PdfDocument(writer);
                Document    document = new Document(pdf);

                // Invocie logo
                ImageData imageData = ImageDataFactory.Create("LawnPro.png");
                Image     pdfImg    = new Image(imageData).ScaleAbsolute(200, 100).SetHorizontalAlignment(HorizontalAlignment.CENTER);
                document.Add(pdfImg);

                // Invoice Header
                Paragraph title = new Paragraph("Lawn Pro Services LLC")
                                  .SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER)
                                  .SetFontSize(20)
                                  .SetBold();
                document.Add(title);

                Paragraph address = new Paragraph("1825 N Bluemound Dr\nAppleton, WI 54912\n(920) 555-5555")
                                    .SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER)
                                    .SetFontSize(15);
                document.Add(address);

                Paragraph customerLabel = new Paragraph("Customer:")
                                          .SetTextAlignment(iText.Layout.Properties.TextAlignment.LEFT)
                                          .SetFontSize(15)
                                          .SetBold()
                                          .SetFixedLeading(15);
                document.Add(customerLabel);

                Paragraph customerAddress = new Paragraph(invoice.CustomerFirstName + " " + invoice.CustomerLastName + "\n" + invoice.CustomerStreetAddress + "\n" + invoice.CustomerCity + ", " + invoice.CustomerState + "  " + invoice.CustomerZip)
                                            .SetTextAlignment(iText.Layout.Properties.TextAlignment.LEFT)
                                            .SetFontSize(15);
                document.Add(customerAddress);


                // Invoice Table
                int rows = 2;
                int cols = 4;

                string[,] data = new string[rows, cols];

                int row = 0;
                data[row, 0] = "Date";
                data[row, 1] = "Service Description";
                data[row, 2] = "Technician";
                data[row, 3] = "Total";
                row++;
                data[row, 0] = invoice.ServiceDate.ToShortDateString();
                data[row, 1] = invoice.ServiceType;
                data[row, 2] = invoice.EmployeeFullName;
                data[row, 3] = invoice.InvoiceTotal.ToString("c2");


                Table table = new Table(cols, false).SetWidth(UnitValue.CreatePercentValue(100));

                for (int iRow = 1; iRow <= rows; iRow++)
                {
                    for (int iCol = 1; iCol <= cols; iCol++)
                    {
                        Cell cell = new Cell(1, 1);
                        cell.Add(new Paragraph(data[iRow - 1, iCol - 1]));

                        if (iRow == 1)
                        {
                            cell.SetBackgroundColor(ColorConstants.LIGHT_GRAY);
                            cell.SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
                            cell.SetBold();
                        }
                        else
                        {
                            if (iRow % 2 == 0)
                            {
                                cell.SetBackgroundColor(ColorConstants.GREEN, .5f);
                            }
                        }

                        if (iCol < 4)
                        {
                            cell.SetTextAlignment(iText.Layout.Properties.TextAlignment.LEFT);
                        }
                        else
                        {
                            cell.SetTextAlignment(iText.Layout.Properties.TextAlignment.RIGHT);
                        }

                        table.AddCell(cell);
                    }
                }

                table.SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER);
                document.Add(table);
                document.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #11
0
        private Table consultausado()
        {
            //estilo titulo tabla
            Style   titulo = new Style();
            PdfFont f      = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLDOBLIQUE);

            titulo.SetFont(f).SetFontSize(16).SetTextAlignment(TextAlignment.CENTER);

            //estilo encabezado
            Style   encabezado = new Style();
            PdfFont f1         = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD);

            encabezado.SetFont(f1).SetFontSize(12).SetTextAlignment(TextAlignment.LEFT);

            //estilo cuerpo general
            Style   cuerpogeneral = new Style();
            PdfFont f2            = PdfFontFactory.CreateFont(StandardFonts.HELVETICA);

            cuerpogeneral.SetFont(f2).SetFontSize(12).SetTextAlignment(TextAlignment.LEFT);

            //creacion de la tabla
            Table table = new Table(new float[5]).UseAllAvailableWidth();

            table.SetMarginTop(0);
            table.SetMarginBottom(0);
            Cell cell = new Cell(1, 5);

            cell.Add(new Paragraph("Reporte de materiales utilizados"));

            cell.AddStyle(titulo);
            cell.SetTextAlignment(TextAlignment.CENTER);
            cell.SetPadding(3);
            cell.SetBackgroundColor(new DeviceRgb(140, 221, 8));
            table.AddCell(cell);

            table.AddCell("Material").AddStyle(encabezado);
            table.AddCell("Cantidad usada en flex").AddStyle(encabezado);
            table.AddCell("Cantidad usada en speed").AddStyle(encabezado);
            table.AddCell("Cantidad usada en 360").AddStyle(encabezado);
            table.AddCell("Cantidad usada en total").AddStyle(encabezado);

            string Query = "SELECT nombre,sum(material_flex),sum(material_speed),sum(material_360) FROM inventarioprograma.materialregistro group by nombre;";

            MySqlConnection MyConn2 = new MySqlConnection(MyConnection2);
            var             cmd     = new MySqlCommand(Query, MyConn2);

            MyConn2.Open();
            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                table.AddCell(new Paragraph(rdr.GetString(0)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(1)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(2)).AddStyle(cuerpogeneral));
                table.AddCell(new Paragraph(rdr.GetString(3)).AddStyle(cuerpogeneral));
                int total = rdr.GetInt32(1) + rdr.GetInt32(2) + rdr.GetInt32(3);
                table.AddCell(new Paragraph(total.ToString()).AddStyle(cuerpogeneral));
            }
            MyConn2.Close();
            return(table);
        }
Пример #12
0
        public void CreateForm()
        {
            PdfDocument pdfDoc = new PdfDocument(new PdfWriter(FORM));
            Document    doc    = new Document(pdfDoc);

            Table table = new Table(1).UseAllAvailableWidth();

            table.AddCell("Written by Alice");
            table.AddCell(CreateSignatureFieldCell("sig1"));
            table.AddCell("For approval by Bob");
            table.AddCell(CreateTextFieldCell("approved_bob"));
            table.AddCell(CreateSignatureFieldCell("sig2"));
            table.AddCell("For approval by Carol");
            table.AddCell(CreateTextFieldCell("approved_carol"));
            table.AddCell(CreateSignatureFieldCell("sig3"));
            table.AddCell("For approval by Dave");
            table.AddCell(CreateTextFieldCell("approved_dave"));
            table.AddCell(CreateSignatureFieldCell("sig4"));
            doc.Add(table);

            doc.Close();
        }
Пример #13
0
        //document header
        private void AddDocHeader()
        {
            Table nhifTable = new Table(5);

            nhifTable.WidthPercentage = 100;
            nhifTable.Padding         = 1;
            nhifTable.Spacing         = 1;
            nhifTable.Border          = Table.NO_BORDER;

            Cell EmployerNameCell = new Cell(new Phrase(_ViewModel.EmployerName.ToUpper() + "\n", new Font(Font.TIMES_ROMAN, 15, Font.BOLD | Font.UNDERLINE, Color.BLACK)));

            EmployerNameCell.HorizontalAlignment = Cell.ALIGN_CENTER;
            EmployerNameCell.Colspan             = 5;
            EmployerNameCell.Border = Cell.NO_BORDER;
            nhifTable.AddCell(EmployerNameCell);

            Cell employerAdressCell = new Cell(new Phrase(_ViewModel.EmpAddress, new Font(Font.TIMES_ROMAN, 9, Font.BOLD | Font.UNDERLINE, Color.BLACK)));

            employerAdressCell.HorizontalAlignment = Cell.ALIGN_CENTER;
            employerAdressCell.Colspan             = 5;
            employerAdressCell.Border = Cell.NO_BORDER;
            nhifTable.AddCell(employerAdressCell);

            Cell bCell = new Cell(new Phrase("NHIF", hFont1));

            bCell.HorizontalAlignment = Cell.ALIGN_CENTER;
            bCell.Colspan             = 5;
            bCell.Border = Cell.NO_BORDER;
            nhifTable.AddCell(bCell);

            Cell reportNameCell = new Cell(new Phrase(_ViewModel.ReportName, hFont2));

            reportNameCell.HorizontalAlignment = Cell.ALIGN_CENTER;
            reportNameCell.Colspan             = 5;
            reportNameCell.Border = Cell.NO_BORDER;
            nhifTable.AddCell(reportNameCell);

            Cell employerNHIFCell = new Cell(new Phrase("NHIF No: " + _ViewModel.EmployerCode.Trim(), hFont2));

            employerNHIFCell.HorizontalAlignment = Cell.ALIGN_CENTER;
            employerNHIFCell.Border  = Cell.NO_BORDER;
            employerNHIFCell.Colspan = 5;
            nhifTable.AddCell(employerNHIFCell);

            Cell PrintedonCell = new Cell(new Phrase("Printed on: " + _ViewModel.PrintedOn.ToString("dd-dddd-MMMM-yyyy"), hFont2));

            PrintedonCell.HorizontalAlignment = Cell.ALIGN_LEFT;
            PrintedonCell.Colspan             = 4;
            PrintedonCell.Border = Cell.NO_BORDER;
            nhifTable.AddCell(PrintedonCell);

            //create the logo
            PDFGen pdfgen = new PDFGen();
            Image  img0   = pdfgen.DoGetImageFile(_ViewModel.CompanyLogo);

            img0.Alignment = Image.ALIGN_MIDDLE;
            Cell logoCell = new Cell(img0);

            logoCell.HorizontalAlignment = Cell.ALIGN_LEFT;
            logoCell.Border = Cell.NO_BORDER;
            logoCell.Add(new Phrase(_ViewModel.CompanySlogan, new Font(Font.HELVETICA, 8, Font.ITALIC, Color.BLACK)));
            nhifTable.AddCell(logoCell);

            document.Add(nhifTable);
        }
Пример #14
0
        public ActionResult Get(string token)
        {
            MemoryStream ms = new MemoryStream();

            PdfWriter   pw          = new PdfWriter(ms);
            PdfDocument pdfDocument = new PdfDocument(pw);
            Document    doc         = new Document(pdfDocument, PageSize.LETTER);

            doc.SetMargins(75, 35, 70, 35);

            string pathLogo = Server.MapPath("~/Content/logo.jpg");
            Image  img      = new Image(ImageDataFactory.Create(pathLogo));

            pdfDocument.AddEventHandler(PdfDocumentEvent.START_PAGE, new HeaderEventHandler(img));
            pdfDocument.AddEventHandler(PdfDocumentEvent.END_PAGE, new FooterEventHandler());


            Table table = new Table(1).UseAllAvailableWidth();
            Cell  cell  = new Cell().Add(new Paragraph("INVOICE").SetFontSize(14)).SetTextAlignment(TextAlignment.CENTER).SetBorder(Border.NO_BORDER);

            table.AddCell(cell);

            doc.Add(table);

            Table _table = new Table(1).UseAllAvailableWidth();

            _table.AddCell(new Cell().Add(new Paragraph("For,")).SetTextAlignment(TextAlignment.RIGHT).SetBorder(Border.NO_BORDER));
            _table.AddCell(new Cell().Add(new Paragraph("Aditya Gaikwad")).SetTextAlignment(TextAlignment.RIGHT).SetBorder(Border.NO_BORDER));
            _table.AddCell(new Cell().Add(new Paragraph("Akurdi, Pune")).SetTextAlignment(TextAlignment.RIGHT).SetBorder(Border.NO_BORDER));


            doc.Add(_table);

            Style styleCell = new Style().SetBackgroundColor(ColorConstants.LIGHT_GRAY).SetTextAlignment(TextAlignment.CENTER);

            _table = new Table(5).UseAllAvailableWidth();
            Cell _cell = new Cell().Add(new Paragraph("#")).SetBorder(Border.NO_BORDER).SetBorderBottom(new SolidBorder(ColorConstants.BLACK, 1)).SetBorderTop(new SolidBorder(ColorConstants.BLACK, 1));

            _table.AddHeaderCell(_cell.AddStyle(styleCell));
            _cell = new Cell().Add(new Paragraph("Book Name")).SetBorder(Border.NO_BORDER).SetBorderBottom(new SolidBorder(ColorConstants.BLACK, 1)).SetBorderTop(new SolidBorder(ColorConstants.BLACK, 1));
            _table.AddHeaderCell(_cell.AddStyle(styleCell));
            _cell = new Cell().Add(new Paragraph("Quantity")).SetBorder(Border.NO_BORDER).SetBorderBottom(new SolidBorder(ColorConstants.BLACK, 1)).SetBorderTop(new SolidBorder(ColorConstants.BLACK, 1));
            _table.AddHeaderCell(_cell.AddStyle(styleCell));
            _cell = new Cell().Add(new Paragraph("Price")).SetBorder(Border.NO_BORDER).SetBorderBottom(new SolidBorder(ColorConstants.BLACK, 1)).SetBorderTop(new SolidBorder(ColorConstants.BLACK, 1));
            _table.AddHeaderCell(_cell.AddStyle(styleCell));
            _cell = new Cell().Add(new Paragraph("Total")).SetBorder(Border.NO_BORDER).SetBorderBottom(new SolidBorder(ColorConstants.BLACK, 1)).SetBorderTop(new SolidBorder(ColorConstants.BLACK, 1));
            _table.AddHeaderCell(_cell.AddStyle(styleCell));

            Customer          customer = (Customer)this.Session["user"];
            List <OrderBooks> books    = BussinessManager.getOrderBooks(token, customer.customerid);

            int    x     = 0;
            double total = 0;

            foreach (OrderBooks book in books)
            {
                x++;
                _cell = new Cell().Add(new Paragraph(x.ToString())).SetBorder(Border.NO_BORDER);
                _table.AddCell(_cell);
                _cell = new Cell().Add(new Paragraph(book.book_name)).SetBorder(Border.NO_BORDER);
                _table.AddCell(_cell);
                _cell = new Cell().Add(new Paragraph(book.quantity.ToString()).SetTextAlignment(TextAlignment.RIGHT)).SetBorder(Border.NO_BORDER);
                _table.AddCell(_cell);
                _cell = new Cell().Add(new Paragraph("₹ " + book.price.ToString()).SetTextAlignment(TextAlignment.RIGHT)).SetBorder(Border.NO_BORDER);
                _table.AddCell(_cell);
                _cell = new Cell().Add(new Paragraph("₹ " + (book.price * book.quantity)).SetTextAlignment(TextAlignment.RIGHT)).SetBorder(Border.NO_BORDER);
                _table.AddCell(_cell);
                total += book.price * book.quantity;
            }

            doc.Add(_table);

            _table = new Table(1).UseAllAvailableWidth();
            _table.AddCell(new Cell().Add(new Paragraph("Total: " + total)).SetTextAlignment(TextAlignment.RIGHT).SetBorder(Border.NO_BORDER).SetBorderBottom(new SolidBorder(ColorConstants.BLACK, 1)).SetBorderTop(new SolidBorder(ColorConstants.BLACK, 1)));

            doc.Add(_table);

            doc.Close();

            byte[] byteStream = ms.ToArray();
            ms = new MemoryStream();
            ms.Write(byteStream, 0, byteStream.Length);
            ms.Position = 0;

            return(new FileStreamResult(ms, "application/pdf"));
        }
Пример #15
0
        private Table InvoiceTotalTable(InvoiceTotalGroupDTO total, bool isCorrection, float posFontSize)
        {
            float headerFontSize = posFontSize * 1.3f;
            var   tableCols      = isCorrection ? new float[] { 2, 2, 2, 2 } : new float[] { 2, 2, 2 };
            var   tbl            = new Table(UnitValue.CreatePercentArray(tableCols));

            tbl.SetWidth(UnitValue.CreatePercentValue(50));

            if (isCorrection)
            {
                tbl.AddCell(TableHeaderCell("RAZEM: ", headerFontSize, 1, 1));
                tbl.AddCell(TableHeaderCell("Netto", headerFontSize, 1, 1));
                tbl.AddCell(TableHeaderCell("Podatek", headerFontSize, 1, 1));
                tbl.AddCell(TableHeaderCell("Brutto", headerFontSize, 1, 1));
                //second row
                tbl.AddCell(PozCell("przed korektą", posFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                tbl.AddCell(PozCell(total.Original.Total_netto.ToString("# ##0.00"), posFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                tbl.AddCell(PozCell(total.Original.Total_tax.ToString("# ##0.00"), posFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                tbl.AddCell(PozCell(total.Original.Total_brutto.ToString("# ##0.00"), posFontSize * 0.9f, TextAlignment.CENTER, 1, 1));

                tbl.AddCell(PozCell("korekta", posFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                tbl.AddCell(PozCell(total.Corrections.Total_netto == 0 ? "-" : total.Corrections.Total_netto.ToString("# ##0.00"), posFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                tbl.AddCell(PozCell(total.Corrections.Total_tax == 0 ? "-" : total.Corrections.Total_tax.ToString("# ##0.00"), posFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                tbl.AddCell(PozCell(total.Corrections.Total_brutto == 0 ? "-" : total.Corrections.Total_brutto.ToString("# ##0.00"), posFontSize * 0.9f, TextAlignment.CENTER, 1, 1));

                tbl.AddCell(PozCell("po korekcie", posFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                tbl.AddCell(PozCell(total.Current.Total_netto.ToString("# ##0.00"), posFontSize * 1.2f, TextAlignment.CENTER, 1, 1));
                tbl.AddCell(PozCell(total.Current.Total_tax.ToString("# ##0.00"), posFontSize * 1.2f, TextAlignment.CENTER, 1, 1));
                tbl.AddCell(PozCell(total.Current.Total_brutto.ToString("# ##0.00"), posFontSize * 1.4f, TextAlignment.CENTER, 1, 1));
            }
            else
            {
                tbl.AddCell(TableHeaderCell("Netto", headerFontSize, 1, 1));
                tbl.AddCell(TableHeaderCell("Podatek", headerFontSize, 1, 1));
                tbl.AddCell(TableHeaderCell("Brutto", headerFontSize, 1, 1));
                //second row
                tbl.AddCell(PozCell(total.Current.Total_netto.ToString("# ##0.00"), posFontSize * 1.2f, TextAlignment.CENTER, 1, 1));
                tbl.AddCell(PozCell(total.Current.Total_tax.ToString("# ##0.00"), posFontSize * 1.2f, TextAlignment.CENTER, 1, 1));
                tbl.AddCell(PozCell(total.Current.Total_brutto.ToString("# ##0.00"), posFontSize * 1.4f, TextAlignment.CENTER, 1, 1));
            }


            //doc.Add(FakCell(inv.InvoiceTotal.Current.Total_netto.ToString("# ##0.00"), "Razem netto", posFontSize * 1.3f, TextAlignment.RIGHT, 1, 1).SetKeepWithNext(true));
            //doc.Add(FakCell(inv.InvoiceTotal.Current.Total_tax > 0 ? inv.InvoiceTotal.Current.Total_tax.ToString("# ##0.00") : "-", "Razem podatek", posFontSize * 1.3f, TextAlignment.RIGHT, 1, 1).SetKeepWithNext(true));
            //doc.Add(FakCell(inv.InvoiceTotal.Current.Total_brutto.ToString("# ##0.00") + $" {inv.Currency.Name}", "Razem brutto", posFontSize * 1.5f, TextAlignment.RIGHT, 1, 1));

            return(tbl);
        }
Пример #16
0
        private void Btn_generar_Click(object sender, RoutedEventArgs e)
        {
            string ruta = @"C:\Reportes Restaurante\Reportes Pedidos";


            if (!Directory.Exists(ruta))
            {
                Console.WriteLine("Creando el directorio: {0}", ruta);
                DirectoryInfo direc = Directory.CreateDirectory(ruta);
            }
            else
            {
                Console.WriteLine("El directorio ya existe, no se ha realizado ninguna acción", ruta);
            }
            //var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var        exportfile = System.IO.Path.Combine(ruta, "reporte.pdf");
            UsuarioBLL usrBLL     = new UsuarioBLL();
            //DataTable dt = usrBLL.Getdatoplato();



            PdfWriter   pw     = new PdfWriter(exportfile);
            PdfDocument pdfDoc = new PdfDocument(pw);
            Document    doc    = new Document(pdfDoc, PageSize.LETTER);

            doc.SetMargins(75, 30, 75, 30);


            Table tb   = new Table(1).UseAllAvailableWidth();
            Cell  cell = new Cell().Add(new Paragraph("Reporte").SetFontSize(14)
                                        .SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER)
                                        .SetBorder(Border.NO_BORDER)
                                        .SetFontColor(ColorConstants.BLUE));

            tb.AddCell(cell);

            doc.Add(tb);

            iText.Layout.Style stylecell = new iText.Layout.Style().SetBackgroundColor(ColorConstants.LIGHT_GRAY).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);

            Table tb2   = new Table(7).UseAllAvailableWidth();
            Cell  cell2 = new Cell().Add(new Paragraph("#"));

            tb2.AddCell(cell2.AddStyle(stylecell));
            cell2 = new Cell().Add(new Paragraph("Proveedor"));
            tb2.AddCell(cell2.AddStyle(stylecell));
            cell2 = new Cell().Add(new Paragraph("Insumo"));
            tb2.AddCell(cell2.AddStyle(stylecell));
            cell2 = new Cell().Add(new Paragraph("Cantidad"));
            tb2.AddCell(cell2.AddStyle(stylecell));
            cell2 = new Cell().Add(new Paragraph("Monto"));
            tb2.AddCell(cell2.AddStyle(stylecell));
            cell2 = new Cell().Add(new Paragraph("Estado"));
            tb2.AddCell(cell2.AddStyle(stylecell));
            cell2 = new Cell().Add(new Paragraph("Fecha"));
            tb2.AddCell(cell2.AddStyle(stylecell));

            int total    = Total(dt);
            int filas    = dt.Rows.Count;
            int contador = 0;

            foreach (DataRow row in dt.Rows)
            {
                cell2 = new Cell().Add(new Paragraph(row["ID PEDIDO"].ToString()));
                tb2.AddCell(cell2);
                cell2 = new Cell().Add(new Paragraph(row["PROVEEDOR"].ToString()));
                tb2.AddCell(cell2);
                cell2 = new Cell().Add(new Paragraph(row["INGREDIENTE"].ToString()));
                tb2.AddCell(cell2);
                cell2 = new Cell().Add(new Paragraph(row["CANTIDAD"].ToString()));
                tb2.AddCell(cell2);
                cell2 = new Cell().Add(new Paragraph(row["MONTO"].ToString()));
                tb2.AddCell(cell2);
                cell2 = new Cell().Add(new Paragraph(row["ESTADO"].ToString()));
                tb2.AddCell(cell2);
                cell2 = new Cell().Add(new Paragraph(row["FECHA"].ToString()));
                tb2.AddCell(cell2);

                int aux = dt.Rows.Count;
                if (contador == aux - 1)
                {
                    cell2 = new Cell().Add(new Paragraph(""));
                    tb2.AddCell(cell2);
                    cell2 = new Cell().Add(new Paragraph(""));
                    tb2.AddCell(cell2);
                    cell2 = new Cell().Add(new Paragraph(""));
                    tb2.AddCell(cell2);
                    cell2 = new Cell().Add(new Paragraph("TOTAL"));
                    tb2.AddCell(cell2);
                    cell2 = new Cell().Add(new Paragraph("" + total));
                    tb2.AddCell(cell2);
                    cell2 = new Cell().Add(new Paragraph(""));
                    tb2.AddCell(cell2);
                    cell2 = new Cell().Add(new Paragraph(""));
                    tb2.AddCell(cell2);
                }
                else
                {
                }
                contador++;
            }
            doc.Add(tb2);
            doc.Close();
            MessageBox.Show("creado");
        }
Пример #17
0
        public void ReporteVentas2()
        {
            FileInfo file = new FileInfo(DEST);

            file.Directory.Create();

            string      dest   = "c:/temp/reporte_ventas1.pdf";
            PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest,
                                                               new WriterProperties().AddUAXmpMetadata().SetPdfVersion
                                                                   (PdfVersion.PDF_1_7)));
            Document document = new Document(pdfDoc, PageSize.LETTER.Rotate());

            //PDF/UA
            //Set document metadata
            pdfDoc.GetCatalog().SetViewerPreferences(new PdfViewerPreferences().SetDisplayDocTitle(true));
            pdfDoc.GetCatalog().SetLang(new PdfString("en-US"));
            PdfDocumentInfo info = pdfDoc.GetDocumentInfo();

            info.SetTitle("Reporte de Ventas de la Semana");

            float[] columnWidths = { 0.5f, 1, 5, 1 };
            Table   tabla        = new Table(UnitValue.CreatePercentArray(columnWidths));

            //tabla.SetWidth();
            tabla.UseAllAvailableWidth();
            PdfFont font = PdfFontFactory.CreateFont(StandardFonts.HELVETICA);
            // celda de encabezado

            Text txt = new Text("Reporte de Ventas Semanal")
                       .SetFontSize(20)
                       .SetBold();

            Paragraph pTitulo = new Paragraph(txt)
                                .SetTextAlignment(TextAlignment.CENTER);

            document.Add(pTitulo);

            //Cell cell = new Cell(1, 4)
            //    .Add(new Paragraph("Reporte de Ventas Semanal"))
            //    .SetFont(font)
            //    .SetFontSize(13)
            //    .SetFontColor(DeviceGray.WHITE)
            //    .SetBackgroundColor(DeviceGray.BLACK)
            //    .SetTextAlignment(TextAlignment.CENTER);

            //tabla.AddHeaderCell(cell);

            for (int i = 0; i < 2; i++)
            {
                Cell[] headerFooter =
                {
                    new Cell()
                    .SetBackgroundColor(new DeviceGray(0.75f))
                    .Add(new Paragraph("No."))
                    .SetBorder(Border.NO_BORDER),
                    new Cell()
                    .SetBackgroundColor(new DeviceGray(0.75f))
                    .Add(new Paragraph("Cant."))
                    .SetBorder(Border.NO_BORDER),
                    new Cell()
                    .SetBackgroundColor(new DeviceGray(0.75f))
                    .Add(new Paragraph("Artículo"))
                    .SetBorder(Border.NO_BORDER),
                    new Cell()
                    .SetBackgroundColor(new DeviceGray(0.75f))
                    .Add(new Paragraph("Total"))
                    .SetBorder(Border.NO_BORDER)
                };

                foreach (Cell hfCell in headerFooter)
                {
                    if (i == 0)
                    {
                        tabla.AddHeaderCell(hfCell);
                    }
                    //    else
                    //    {
                    //        tabla.AddFooterCell(hfCell);
                    //    }
                }
            }

            for (int j = 0; j < 10; j++)
            {
                tabla.AddCell(new Cell()
                              .SetTextAlignment(TextAlignment.CENTER)
                              .Add(new Paragraph((j + 1).ToString())));
                tabla.AddCell(new Cell()
                              .SetTextAlignment(TextAlignment.CENTER)
                              .Add(new Paragraph("cantidad " + (j + 1))));
                tabla.AddCell(new Cell()
                              .SetTextAlignment(TextAlignment.CENTER)
                              .Add(new Paragraph("lapiz adhesivo resistol no tóxico 100gr -- lapiz adhesivo resistol no tóxico 100gr " + (j + 1))));
                tabla.AddCell(new Cell()
                              .SetTextAlignment(TextAlignment.RIGHT)
                              .Add(new Paragraph("$100" + (j + 1))));
            }

            document.Add(tabla);
            Paragraph p = new Paragraph();

            p.SetTextAlignment(TextAlignment.RIGHT);
            p.Add("Total de la semana: $" + 10000);

            document.Add(p);

            document.Close();
        }
Пример #18
0
        public IElement[] GetElements()
        {
            List <IElement> result = new List <IElement>();

            float[] columnWidth = { 150, 150 };
            Table   table       = new Table(columnWidth);

            table.UseAllAvailableWidth();

            // add image

            Cell imageCell = new Cell().SetBorder(Border.NO_BORDER); //

            imageCell.SetWidth(imageWidth);
            imageCell.Add(GetImage(ProfileImage));
            table.AddCell(imageCell);

            // add personal info

            Cell nameCell = new Cell();

            nameCell.SetBorder(Border.NO_BORDER);
            foreach (var item in GetName())
            {
                nameCell.Add(item);
            }
            foreach (var item in GetText(Birthday))
            {
                nameCell.Add(item);
            }
            table.AddCell(nameCell);

            result.Add(table);

            // ADD CONTANT INFO

            float[] columnWidthContact = { 150, 150, 150, 150 };
            Table   tableContact       = new Table(columnWidthContact);

            tableContact.UseAllAvailableWidth();

            foreach (var parag in GetContactInfo())
            {
                Cell cellContact = new Cell();

                cellContact.Add(parag);
                cellContact.SetBorder(Border.NO_BORDER);

                tableContact.AddCell(cellContact);
            }
            Color bgContact = new DeviceRgb(240, 240, 240);

            tableContact.SetBackgroundColor(bgContact);
            result.Add(tableContact);

            // ADD EXP and Education
            float[] columnWidthExpAndEducation = { 150, 150 };
            Table   table_ExpAndEducation      = new Table(columnWidthExpAndEducation);

            table_ExpAndEducation.UseAllAvailableWidth();

            // add exp
            Cell cellExp = new Cell();

            cellExp.SetBorder(Border.NO_BORDER);
            foreach (var item in GetBlock(Experience))
            {
                cellExp.Add(item);
            }
            table_ExpAndEducation.AddCell(cellExp);

            // add education
            Cell cellEduc = new Cell();

            cellEduc.SetBorder(Border.NO_BORDER);
            foreach (var item in GetBlock(Education))
            {
                cellEduc.Add(item);
            }
            table_ExpAndEducation.AddCell(cellEduc);

            result.Add(table_ExpAndEducation);

            return(result.ToArray());
        }
        public IActionResult Get()
        {
            List <CasesAndDeaths> patients = dbcontext.CasesAndDeaths
                                             .FromSqlRaw("EXECUTE user_public.deaths_and_cases").ToList();

            MemoryStream m = new MemoryStream();

            PdfWriter   writer   = new PdfWriter(m);
            PdfDocument pdf      = new PdfDocument(writer);
            Document    document = new Document(pdf, PageSize.A4, false);


            Paragraph header = new Paragraph("New cases and deaths report")
                               .SetTextAlignment(TextAlignment.CENTER)
                               .SetFontSize(30);

            document.Add(header);

            LineSeparator ls = new LineSeparator(new SolidLine());

            document.Add(ls);

            Table table = new Table(9, false);
            Cell  h1    = new Cell(1, 1)
                          .SetBackgroundColor(ColorConstants.LIGHT_GRAY)
                          .SetTextAlignment(TextAlignment.CENTER)
                          .Add(new Paragraph("Country"));

            Cell h2 = new Cell(1, 1)
                      .SetBackgroundColor(ColorConstants.LIGHT_GRAY)
                      .SetTextAlignment(TextAlignment.CENTER)
                      .Add(new Paragraph("Type"));

            Cell h3 = new Cell(1, 1)
                      .SetTextAlignment(TextAlignment.CENTER)
                      .SetBackgroundColor(ColorConstants.LIGHT_GRAY)
                      .Add(new Paragraph(DateTime.Now.AddDays(-6).ToString("yyyy-MM-dd")));

            Cell h4 = new Cell(1, 1)
                      .SetTextAlignment(TextAlignment.CENTER)
                      .SetBackgroundColor(ColorConstants.LIGHT_GRAY)
                      .Add(new Paragraph(DateTime.Now.AddDays(-5).ToString("yyyy-MM-dd")));

            Cell h5 = new Cell(1, 1)
                      .SetTextAlignment(TextAlignment.CENTER)
                      .SetBackgroundColor(ColorConstants.LIGHT_GRAY)
                      .Add(new Paragraph(DateTime.Now.AddDays(-4).ToString("yyyy-MM-dd")));

            Cell h6 = new Cell(1, 1)
                      .SetBackgroundColor(ColorConstants.LIGHT_GRAY)
                      .SetTextAlignment(TextAlignment.CENTER)
                      .Add(new Paragraph(DateTime.Now.AddDays(-3).ToString("yyyy-MM-dd")));

            Cell h7 = new Cell(1, 1)
                      .SetBackgroundColor(ColorConstants.LIGHT_GRAY)
                      .SetTextAlignment(TextAlignment.CENTER)
                      .Add(new Paragraph(DateTime.Now.AddDays(-2).ToString("yyyy-MM-dd")));

            Cell h8 = new Cell(1, 1)
                      .SetBackgroundColor(ColorConstants.LIGHT_GRAY)
                      .SetTextAlignment(TextAlignment.CENTER)
                      .Add(new Paragraph(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")));

            Cell h9 = new Cell(1, 1)
                      .SetBackgroundColor(ColorConstants.LIGHT_GRAY)
                      .SetTextAlignment(TextAlignment.CENTER)
                      .Add(new Paragraph(DateTime.Now.ToString("yyyy-MM-dd")));

            table.AddHeaderCell(h1);
            table.AddHeaderCell(h2);
            table.AddHeaderCell(h3);
            table.AddHeaderCell(h4);
            table.AddHeaderCell(h5);
            table.AddHeaderCell(h6);
            table.AddHeaderCell(h7);
            table.AddHeaderCell(h8);
            table.AddHeaderCell(h9);


            foreach (var p in patients)
            {
                Cell r1 = new Cell(1, 1)
                          .SetTextAlignment(TextAlignment.CENTER)
                          .Add(new Paragraph(p.Country));

                Cell r2 = new Cell(1, 1)
                          .SetTextAlignment(TextAlignment.CENTER)
                          .Add(new Paragraph(p.Type));

                Cell r3 = new Cell(1, 1)
                          .SetTextAlignment(TextAlignment.CENTER)
                          .Add(new Paragraph(p.Fecha1.ToString()));

                Cell r4 = new Cell(1, 1)
                          .SetTextAlignment(TextAlignment.CENTER)
                          .Add(new Paragraph(p.Fecha2.ToString()));

                Cell r5 = new Cell(1, 1)
                          .SetTextAlignment(TextAlignment.CENTER)
                          .Add(new Paragraph(p.Fecha3.ToString()));

                Cell r6 = new Cell(1, 1)
                          .SetTextAlignment(TextAlignment.CENTER)
                          .Add(new Paragraph(p.Fecha4.ToString()));

                Cell r7 = new Cell(1, 1)
                          .SetTextAlignment(TextAlignment.CENTER)
                          .Add(new Paragraph(p.Fecha5.ToString()));

                Cell r8 = new Cell(1, 1)
                          .SetTextAlignment(TextAlignment.CENTER)
                          .Add(new Paragraph(p.Fecha6.ToString()));

                Cell r9 = new Cell(1, 1)
                          .SetTextAlignment(TextAlignment.CENTER)
                          .Add(new Paragraph(p.Fecha7.ToString()));

                table.AddCell(r1);
                table.AddCell(r2);
                table.AddCell(r3);
                table.AddCell(r4);
                table.AddCell(r5);
                table.AddCell(r6);
                table.AddCell(r7);
                table.AddCell(r8);
                table.AddCell(r9);
            }

            Paragraph newline = new Paragraph(new Text("\n"));

            table.UseAllAvailableWidth();

            document.Add(newline);
            document.Add(table);


            int n = pdf.GetNumberOfPages();

            for (int i = 1; i <= n; i++)
            {
                document.ShowTextAligned(new Paragraph(string
                                                       .Format("page" + i + " of " + n)),
                                         559, 806, i, TextAlignment.RIGHT,
                                         VerticalAlignment.TOP, 0);
            }

            document.Close();

            return(File(m.ToArray(), "application/pdf"));
        }
Пример #20
0
        public MemoryStream InvoicePdf(InvoiceSellDTO inv)
        {
            MemoryStream ms  = new MemoryStream();
            var          doc = this.DefaultPdfDoc(ms);


            bool   isCorr          = inv.IsCorrection;
            string invoiceTypeName = inv.IsCorrection ? "Faktura korygująca" : "Faktura VAT";
            string subTitle        = isCorr ? $"Do dokumentu: {inv.InvoiceOriginalNo}" : null;
            var    headerCompany   = this.HederCompanyGen(inv.CompanySeller, "Sprzedawca", inv.CompanyBuyer, "Nabywca", $"{invoiceTypeName} {inv.InvoiceNo}", subTitle);

            float posFontSize = 9f;

            doc.Add(FakCell(inv.DateOfSell.ToShortDateString(), "Data sprzedaży", posFontSize, TextAlignment.RIGHT, 1, 1));
            doc.Add(FakCell(inv.DateOfIssue.ToShortDateString(), "Data wystawienia", posFontSize, TextAlignment.RIGHT, 1, 1));
            doc.Add(headerCompany);

            doc.Add(EmptyCell(1, 1));
            var invListTable = this.InvoiceLinesTable(inv.InvoiceLines, posFontSize, isCorr);

            doc.Add(invListTable);
            doc.Add(EmptyCell(1, 1));

            var rates = this.InvoiceRatesTable(inv.Rates.OrderByDescending(o => o.Current.Vat_rate).ToList(), posFontSize, isCorr);

            rates.SetHorizontalAlignment(HorizontalAlignment.RIGHT);
            rates.SetKeepTogether(true);
            rates.SetMarginTop(posFontSize);

            doc.Add(rates);

            var totalTable = this.InvoiceTotalTable(inv.InvoiceTotal, isCorr, posFontSize);

            totalTable.SetMarginTop(posFontSize);
            totalTable.SetMarginBottom(posFontSize);
            totalTable.SetHorizontalAlignment(HorizontalAlignment.RIGHT);
            doc.Add(totalTable);



            if (isCorr)
            {
                //var leftToPayValue = inv.invoiceOriginalPaid?
            }

            var leftToPay = FakCell(inv.GetCorrectionPaymenntInfo, null, posFontSize * 2f, TextAlignment.RIGHT, 1, 1);

            doc.Add(leftToPay);

            doc.Add(FakCell($"{inv.Currency.Name} ({inv.Currency.Description})", "Waluta", posFontSize * 1.3f, TextAlignment.LEFT, 1, 1));
            if (isCorr)
            {
                var terms = inv.PaymentTerms;

                var dayDays = terms.PaymentDays > 1 ? "dni" : "dzień";
                var isDays  = terms.PaymentTerm.IsPaymentDate ? $", {terms.PaymentDays} {dayDays}" : null;
                doc.Add(FakCell($"{terms.PaymentTerm.Name}{isDays}", "Forma płatności", posFontSize * 1.3f, TextAlignment.LEFT, 1, 1));
            }
            else
            {
                doc.Add(FakCell(inv.PaymentTerms.PaymentTermsCombined, "Forma płatności, termin", posFontSize * 1.3f, TextAlignment.LEFT, 1, 1));
            }


            if (inv.ExtraInfo.Is_in_words)
            {
                doc.Add(FakCell(inv.ExtraInfo.Total_brutto_in_words, "Słownie brutto", posFontSize * 1.3f, TextAlignment.LEFT, 1, 1));
            }
            if (inv.ExtraInfo.Is_load_no)
            {
                if (inv.ExtraInfo.TransportOfferNo != null)
                {
                    doc.Add(FakCell(inv.ExtraInfo.TransportOfferNo, "Zlecenie nr", posFontSize * 1.3f, TextAlignment.LEFT, 1, 1));
                }
                else
                {
                    doc.Add(FakCell(inv.ExtraInfo.LoadNo, "Zlecenie nr", posFontSize * 1.3f, TextAlignment.LEFT, 1, 1));
                }
            }
            if (inv.ExtraInfo.Is_tax_nbp_exchanged)
            {
                doc.Add(FakCell(inv.ExtraInfo.Tax_exchanged_info, "Przelicznik", posFontSize * 1.3f, TextAlignment.LEFT, 1, 1));
            }
            if (!string.IsNullOrWhiteSpace(inv.Info))
            {
                doc.Add(FakCell(inv.Info, "Uwagi", posFontSize * 1.3f, TextAlignment.LEFT, 1, 1));
            }

            if (inv.ExtraInfo.IsSigningPlace)
            {
                var signingTable = new Table(UnitValue.CreatePercentArray(new float[] { 3, 2, 3 })); //3 cols
                signingTable.SetWidth(UnitValue.CreatePercentValue(100));

                signingTable.AddCell(FakCell("...................................................................", null, posFontSize, TextAlignment.CENTER, 1, 1));
                signingTable.AddCell(EmptyCell());
                signingTable.AddCell(FakCell("...................................................................", null, posFontSize, TextAlignment.CENTER, 1, 1));

                signingTable.AddCell(FakCell("Podpis osoby upoważnionej do odebrania faktury", null, posFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                signingTable.AddCell(EmptyCell());
                signingTable.AddCell(FakCell("Podpis osoby upoważnionej do wystawienia faktury", null, posFontSize * 0.8f, TextAlignment.CENTER, 1, 1));

                signingTable.SetMarginTop(posFontSize * 10f);
                doc.Add(signingTable);
            }


            if (doc.GetPdfDocument().GetNumberOfPages() > 1)
            {
                doc.GetPdfDocument().AddEventHandler(PdfDocumentEvent.END_PAGE, new InvoiceFooter(doc, this.FontExoThin, inv.GetInvoiceNo));
            }
            doc.Close();
            return(ms);
        }
Пример #21
0
        public void creaPdf()
        {
            DateTime fecha       = DateTime.Now;
            string   fechaActual = fecha.ToString("dd-MM-yyyy");
            //string ruta = 'C:\Users\M.ibarraO\Documents\DUOC\Aplicaciones\GeneraPDF\Listado_ClienteActual_' + fechaActual+'.pdf';

            PdfWriter pdfwriter = new PdfWriter("C:\\Listado_ClienteActual_" + fechaActual + ".pdf");
            //Crear documento
            PdfDocument pdf       = new PdfDocument(pdfwriter);
            Document    documento = new Document(pdf, PageSize.LETTER);

            documento.SetMargins(60, 20, 55, 20);

            PdfFont fontColumnas  = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD);
            PdfFont fontContenido = PdfFontFactory.CreateFont(StandardFonts.HELVETICA);

            string[] columnas = { "nombre", "paterno", "materno", "rut", "dv", "rubro", "direccion", "codcomuna", "telefono", "mail" };
            float[]  tamanios = { 10, 10, 10, 10, 1, 10, 20, 10, 9, 20 };

            Table tabla = new Table(UnitValue.CreatePercentArray(tamanios));

            tabla.SetWidth(UnitValue.CreatePercentValue(100));

            foreach (string columna in columnas)
            {
                tabla.AddHeaderCell(new Cell().Add(new Paragraph(columna).SetFont(fontColumnas)));
            }

            /*CONSULTA SQL*/

            OracleConnection conn         = D_Conexion.conectar();
            List <eCliente>  listaCliente = new List <eCliente>();

            try
            {
                OracleCommand command = conn.CreateCommand();
                command.CommandText = "select nombre,appaterno,apmaterno,rut,dverificador,descripcionrubro,direccion,nombrecomuna,telefono,email  from cliente cl inner join comuna cm on cm.idcomuna = cl.codcomuna inner join ciudad cd on cd.idciudad = cm.idciudad inner join region rg on rg.idregion = cd.idregion inner join rubro rb on rb.idrubro = cl.idrubro";
                OracleDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    // tabla.AddCell(new Cell().Add(new Paragraph(reader["IDCLIENTE"].ToString())));
                    tabla.AddCell(new Cell().Add(new Paragraph(reader["NOMBRE"].ToString())));
                    tabla.AddCell(new Cell().Add(new Paragraph(reader["APPATERNO"].ToString())));
                    tabla.AddCell(new Cell().Add(new Paragraph(reader["APMATERNO"].ToString())));
                    tabla.AddCell(new Cell().Add(new Paragraph(reader["RUT"].ToString())));
                    tabla.AddCell(new Cell().Add(new Paragraph(reader["DVERIFICADOR"].ToString())));
                    tabla.AddCell(new Cell().Add(new Paragraph(reader["descripcionrubro"].ToString())));
                    tabla.AddCell(new Cell().Add(new Paragraph(reader["DIRECCION"].ToString())));
                    tabla.AddCell(new Cell().Add(new Paragraph(reader["NOMBRECOMUNA"].ToString())));
                    //tabla.AddCell(new Cell().Add(new Paragraph(reader["NOMBRECIUDAD"].ToString())));
                    //tabla.AddCell(new Cell().Add(new Paragraph(reader["NOMBREREGION"].ToString())));
                    tabla.AddCell(new Cell().Add(new Paragraph(reader["TELEFONO"].ToString())));
                    tabla.AddCell(new Cell().Add(new Paragraph(reader["EMAIL"].ToString())));
                }

                command.Dispose();
                reader.Close();
                reader.Dispose();

                //Agrega en la tablapdf
                documento.Add(tabla);
                documento.Close();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
Пример #22
0
        public MemoryStream LoadOfferPdf(LoadDTO loadDTO)
        {
            var ms  = new MemoryStream();
            var doc = this.DefaultPdfDoc(ms);



            var tblNaglowek = this.HederCompanyGen(loadDTO.Sell.Principal, "Zleceniodawca", loadDTO.Sell.Selling_info.Company, "Zleceniobiorca/Przewoźnik", $"Zlecenie przewozowe nr {loadDTO.LoadNo}");

            var tblRoutes = new Table(UnitValue.CreatePercentArray(new float[] { 2, 2, 2, 2, 1, 1, 2, 2 })); //8 cols


            int   routeIdx      = 1;
            float routeFontSize = 8f;

            foreach (var route in loadDTO.Buy.Routes)
            {
                var palletsCount = route.Pallets.Count;

                tblRoutes.AddCell(FakCell($"{routeIdx}) {route.Loading_type}", null, routeFontSize * 1f, TextAlignment.LEFT, 1 + palletsCount, 1));
                tblRoutes.AddCell(FakCell($"{route.Loading_date.ToShortDateString()} {route.Loading_date.ToShortTimeString()}", null, routeFontSize, TextAlignment.LEFT, 1, 1));
                tblRoutes.AddCell(FakCell(route.Address.AddressCombined, null, routeFontSize, TextAlignment.LEFT, 1, 2));
                //pallets count>0 1st row
                if (route.Pallets.Count > 0)
                {
                    tblRoutes.AddCell(FakCell("Typ palety", null, routeFontSize * 0.5f, TextAlignment.CENTER, 1, 1).SetFontColor(ColorConstants.GRAY));
                    tblRoutes.AddCell(FakCell("Ilość", null, routeFontSize * 0.5f, TextAlignment.CENTER, 1, 1).SetFontColor(ColorConstants.GRAY));
                    tblRoutes.AddCell(FakCell("Info", null, routeFontSize * 0.5f, TextAlignment.CENTER, 1, 2).SetFontColor(ColorConstants.GRAY));
                }
                else
                {
                    //tblNaglowek.AddCell(PustaCell(1, 3));
                    tblRoutes.AddCell(FakCell(route.Info, null, routeFontSize * 0.8f, TextAlignment.LEFT, 1, 5));
                }


                //pallets count>0 2nd row
                if (route.Pallets.Count > 0)
                {
                    int palletIdx = 0;
                    foreach (var pallet in route.Pallets)
                    {
                        List <string> routeInfoArr = new List <string>();
                        string        rInfo;
                        string        routeInfo;

                        if (!string.IsNullOrWhiteSpace(pallet.Info))
                        {
                            routeInfoArr.Add(pallet.Info);
                        }
                        if (pallet.Type.Value == "other")
                        {
                            routeInfoArr.Add(pallet.Dimmension);
                        }
                        if (pallet.Type.Value == "other" && pallet.Is_exchangeable.HasValue && pallet.Is_exchangeable.Value)
                        {
                            routeInfoArr.Add("wymienialna");
                        }
                        if (pallet.Type.Value == "other" && pallet.Is_stackable.HasValue && pallet.Is_stackable.Value)
                        {
                            routeInfoArr.Add("piętrowalna");
                        }
                        rInfo     = string.Join(", ", routeInfoArr);
                        routeInfo = palletIdx == 0 ? route.Info : null;

                        tblRoutes.AddCell(FakCell(routeInfo, null, routeFontSize * 0.8f, TextAlignment.LEFT, 1, 3));
                        tblRoutes.AddCell(FakCell(pallet.Type.Value, null, routeFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                        tblRoutes.AddCell(FakCell(pallet.Amount.ToString(), null, routeFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                        tblRoutes.AddCell(FakCell(rInfo, null, routeFontSize * 0.8f, TextAlignment.CENTER, 1, 2));

                        palletIdx++;
                    }
                }

                routeIdx++;
                tblRoutes.AddCell(EmptyCell(1, 8).SetBorderTop(new SolidBorder(ColorConstants.LIGHT_GRAY, 1, 0.5f)));
            }

            var           extraInfo = loadDTO.Buy.Load_info.ExtraInfo;
            List <string> infoArr   = new List <string>();

            infoArr.Add(extraInfo.Required_truck_body.ViewValue);
            if (extraInfo.Is_for_clearence.HasValue && extraInfo.Is_for_clearence.Value)
            {
                infoArr.Add("do oclenia (for clearence)");
            }
            if (extraInfo.Is_ltl.HasValue && extraInfo.Is_ltl.Value)
            {
                infoArr.Add("doładunek (LTL)");
            }
            if (extraInfo.Is_lift_required.HasValue && extraInfo.Is_lift_required.Value)
            {
                infoArr.Add("wymagana winda (lift)");
            }
            if (extraInfo.Is_tir_cable_required.HasValue && extraInfo.Is_tir_cable_required.Value)
            {
                infoArr.Add("wymagana linka celna (tir cable)");
            }
            if (extraInfo.Is_tracking_system_required.HasValue && extraInfo.Is_tracking_system_required.Value)
            {
                infoArr.Add("wymagany GPS");
            }
            if (extraInfo.Is_truck_crane_required.HasValue && extraInfo.Is_truck_crane_required.Value)
            {
                infoArr.Add("gotowy do załadunku (truck crane)");
            }
            if (extraInfo.Required_adr_classes.Count > 0)
            {
                var adr = extraInfo.Required_adr_classes.Select(s => s.ViewValue.Trim().ToLower()).ToList();
                infoArr.Add($"ADR:  ({string.Join(", ", adr)})");
            }
            if (extraInfo.Type_of_load != null)
            {
                infoArr.Add(extraInfo.Type_of_load.ViewValue);
            }
            var loadInfo = loadDTO.Buy.Load_info;

            if (loadInfo.Load_height.HasValue && loadInfo.Load_length.HasValue && loadInfo.Load_volume.HasValue)
            {
                infoArr.Add($"Wymiary ładunku: wys/dł/obj/ciężar ({loadInfo.Load_height.Value}/{loadInfo.Load_length.Value}/{loadInfo.Load_volume.Value}/{loadInfo.Load_weight})");
            }



            float  headerFontSize = 8f;
            string wartosc        = loadDTO.Sell.Selling_info.Price.Price.ToString("0.00");

            doc.Add(tblNaglowek);
            doc.Add(HeaderCell($"Stawka frachtowa: {wartosc} {loadDTO.Sell.Selling_info.Price.Currency.Name}, termin płatności: {loadDTO.Sell.Selling_info.PaymentTerms.PaymentDays.Value} dni, ALL-IN", headerFontSize));

            doc.Add(HeaderCell("Kontakt", headerFontSize));
            doc.Add(FakCell($"PO ZAŁADUNKU I ROZŁADUNKU PROSZĘ O SMS NA NR {loadDTO.Sell.ContactPersonsList.FirstOrDefault().Telephone} !!!! Przewoźnik ma obowiązek udzielania informacji o aktualnym położeniu samochodu,  brak tych informacji spowoduje obniżenie frachtu o 50 euro ! Kierowca ma obowiązek zweryfikować towar podczas załadunku pod względem jakościowym i ilościowym, a wszystkie zastrzeżenia co do jego jakości muszą być wpisane w dokument CMR. ", null, 6f, TextAlignment.LEFT, 1, 1));
            foreach (var contactPerson in loadDTO.Sell.ContactPersonsList.ToList())
            {
                doc.Add(FakCell(contactPerson.CompanyEmployeeInfo, null, routeFontSize, TextAlignment.LEFT, 1, 1));
            }

            doc.Add(HeaderCell("Trasa:", headerFontSize));
            doc.Add(tblRoutes);
            doc.Add(HeaderCell("Info", headerFontSize));
            doc.Add(FakCell($"[{string.Join(", ", infoArr)}]", "extra info", routeFontSize, TextAlignment.LEFT, 1, 1));

            //regulamin
            int   regIdx      = 1;
            float regFontSize = 6f;

            doc.Add(HeaderCell("Ogólne warunki zlecenia", headerFontSize));
            foreach (var reg in this.Regulamin())
            {
                doc.Add(FakCell(reg, $"{ regIdx})", regFontSize, TextAlignment.LEFT, 1, 1));
                regIdx++;
            }



            doc.Close();
            return(ms);
        }
Пример #23
0
        private void BuildP10PDF()
        {
            try
            {
                document = new Document(PageSize.A4.Rotate());

                PdfWriter.GetInstance(document, new FileStream(sFilePDF, FileMode.Create));

                document.Open();

                PDFGen pdfgen = new PDFGen();
                Image  img0   = pdfgen.DoGetImageFile(_resourcePath + "kra2.jpg");
                img0.Alignment = Image.ALIGN_CENTER;

                Table empInfoTable = new Table(3, 3);
                empInfoTable.WidthPercentage = 100;
                empInfoTable.Border          = Table.NO_BORDER;

                Phrase header1 = new Phrase(_ViewModel.ReportName, hFont2);
                Cell   c2      = new Cell(header1);
                c2.Border = Cell.NO_BORDER;
                c2.HorizontalAlignment = Cell.ALIGN_CENTER;
                // c1.Colspan = 3;
                empInfoTable.AddCell(c2, new System.Drawing.Point(1, 1));

                // Phrase header1 = new Phrase(p9A.ReportName, hFont2);
                Cell c1 = new Cell(img0);// header1);
                c1.Border = Cell.NO_BORDER;
                c1.HorizontalAlignment = Cell.ALIGN_CENTER;
                // c1.Colspan = 3;

                empInfoTable.AddCell(c1, new System.Drawing.Point(0, 1));

                Chunk name        = new Chunk("_ViewModel", bFont1);
                Cell  empPINCell1 = new Cell(name);
                empPINCell1.Border = Cell.NO_BORDER;
                empInfoTable.AddCell(empPINCell1, new System.Drawing.Point(1, 0));

                Chunk employerPIN = new Chunk("Employer's PIN ..." + _ViewModel.EmployerPin.Trim() + "...", bFont1);
                Cell  empPINCell  = new Cell(employerPIN);
                empPINCell.Border = Cell.NO_BORDER;
                empInfoTable.AddCell(empPINCell, new System.Drawing.Point(1, 2));

                document.Add(empInfoTable);

                Table empInfoTable2 = new Table(1, 4);
                empInfoTable2.WidthPercentage = 100;
                empInfoTable2.Border          = Table.NO_BORDER;

                Phrase header2 = new Phrase("To Senior Assistant Commissioner...........\n", bFont1);

                Cell c3 = new Cell(header2);
                c3.Border = Cell.NO_BORDER;
                c3.HorizontalAlignment = Cell.ALIGN_LEFT;
                c3.VerticalAlignment   = Cell.ALIGN_CENTER;
                empInfoTable2.AddCell(c3, new System.Drawing.Point(1, 0));

                Chunk info  = new Chunk("We/I forward herewith...................Tax Deduction Cards(P9A/P9B)showing the Total tax deducted\n (as listed on P10A) amounting to Kshs........" + _ViewModel.TotalPAYETax.ToString("#,##0") + "\n This Total tax has been paid as follows:-    ", bFont1);
                Cell  info1 = new Cell(info);
                info1.Border = Cell.NO_BORDER;
                info1.HorizontalAlignment = Cell.ALIGN_LEFT;
                empInfoTable2.AddCell(info1, new System.Drawing.Point(2, 0));

                Chunk info2 = new Chunk(".", bFont1);
                Cell  info3 = new Cell(info2);
                info3.Border = Cell.NO_BORDER;
                info3.HorizontalAlignment = Cell.ALIGN_LEFT;

                empInfoTable2.AddCell(info3, new System.Drawing.Point(3, 0));

                document.Add(empInfoTable2);

                Table taxTable = new Table(5, 14);
                taxTable.Padding         = 1;
                taxTable.Spacing         = 1;
                taxTable.WidthPercentage = 100;

                //Add table headers
                AddTableHeaders(taxTable);

                for (int i = 1; i <= 12; i++)
                {
                    var monthRecs = (from mr in _ViewModel.P10tax
                                     where mr.MonthInt == i
                                     select mr).SingleOrDefault();
                    AddTableRow(i, taxTable, monthRecs);
                }

                //Add totals
                AddTotals(taxTable);

                document.Add(taxTable);

                AddFooter();

                document.Close();
            }
            catch (DocumentException de)
            {
                this.Message = de.Message;
            }
            catch (IOException ioe)
            {
                this.Message = ioe.Message;
            }
            catch (Exception ex)
            {
                Log.WriteToErrorLogFile(ex);
            }
        }
Пример #24
0
        private Table HederCompanyGen(CompanyDTO companyOnLeft, string leftHeaderTitle, CompanyDTO companyOnRight, string rightHeaderTitle, string title, string subTitle = null)
        {
            var tblNaglowek = new Table(UnitValue.CreatePercentArray(new float[] { 4, 4, 1, 4, 4 }));

            //var companyOnLeft=

            //doc.Add(tblNaglowek);
            float fSize = 9f;

            tblNaglowek.AddCell(FakCell(title, null, fSize * 1.8f, TextAlignment.CENTER, 1, 5));
            if (!string.IsNullOrWhiteSpace(subTitle))
            {
                tblNaglowek.AddCell(FakCell(subTitle, null, fSize * 0.9f, TextAlignment.CENTER, 1, 5));
            }
            tblNaglowek.AddCell(EmptyCell(2, 5));
            tblNaglowek.AddCell(FakCell(leftHeaderTitle, null, fSize * 1.5f, TextAlignment.CENTER, 2, 2).SetBold());
            tblNaglowek.AddCell(EmptyCell(2, 1));
            tblNaglowek.AddCell(FakCell(rightHeaderTitle, null, fSize * 1.5f, TextAlignment.CENTER, 2, 2).SetBold());
            tblNaglowek.AddCell(FakCell(companyOnLeft.Legal_name, null, fSize * 1.2f, TextAlignment.CENTER, 2, 2));
            tblNaglowek.AddCell(EmptyCell(2, 1));
            tblNaglowek.AddCell(FakCell(companyOnRight.Legal_name, null, fSize * 1.2f, TextAlignment.CENTER, 2, 2));
            tblNaglowek.AddCell(FakCell(companyOnLeft.AddressList[0].AddressCombined, null, fSize * 0.9f, TextAlignment.CENTER, 1, 2));
            tblNaglowek.AddCell(EmptyCell(1, 1));
            tblNaglowek.AddCell(FakCell(companyOnRight.AddressList[0].AddressCombined, null, fSize * 0.9f, TextAlignment.CENTER, 1, 2));
            tblNaglowek.AddCell(FakCell("NIP: " + companyOnLeft.Vat_id, null, fSize * 1.1f, TextAlignment.CENTER, 1, 2));
            tblNaglowek.AddCell(EmptyCell(1, 1));
            tblNaglowek.AddCell(FakCell("NIP: " + companyOnRight.Vat_id, null, fSize * 1.1f, TextAlignment.CENTER, 1, 3));
            tblNaglowek.AddCell(FakCell(companyOnLeft.ContactInfo, null, fSize * 0.7f, TextAlignment.CENTER, 1, 2));
            tblNaglowek.AddCell(EmptyCell(1, 1));
            tblNaglowek.AddCell(FakCell(companyOnRight.ContactInfo, null, fSize * 0.7f, TextAlignment.CENTER, 1, 2));


            var bankAccountsleft   = companyOnLeft.BankAccountList.Count;
            var bankAccountsRight  = companyOnRight.BankAccountList.Count;
            int bankAccountsLength = bankAccountsleft >= bankAccountsRight ? bankAccountsleft : bankAccountsRight;


            if (bankAccountsLength > 0)
            {
                for (int i = 0; i < bankAccountsLength; i++)
                {
                    if (bankAccountsleft - 1 >= i && bankAccountsleft > 0)
                    {
                        var bankAccount = companyOnLeft.BankAccountList[i];
                        tblNaglowek.AddCell(FakCell($"{bankAccount.Swift} {bp.shared.StringHelp.StringHelpful.SeparatorEveryBeginningEnd(bankAccount.Account_no)}", bankAccount.Type, fSize * 0.9f, TextAlignment.LEFT, 1, 2));
                    }
                    else
                    {
                        tblNaglowek.AddCell(EmptyCell(1, 2));
                    }

                    tblNaglowek.AddCell(EmptyCell(1, 1));

                    if (bankAccountsRight - 1 >= i && bankAccountsRight > 0)
                    {
                        var bankAccount = companyOnRight.BankAccountList[i];
                        tblNaglowek.AddCell(FakCell($"{bankAccount.Swift} {bp.shared.StringHelp.StringHelpful.SeparatorEveryBeginningEnd(bankAccount.Account_no)}", bankAccount.Type, fSize * 0.9f, TextAlignment.RIGHT, 1, 2));
                    }
                    else
                    {
                        tblNaglowek.AddCell(EmptyCell(1, 2));
                    }
                }
            }



            tblNaglowek.AddCell(EmptyCell(1, 5));
            return(tblNaglowek);
        }
Пример #25
0
        private void AddTotals(Table aTable)
        {
            //Total Emoluments
            aTable.AddCell(new Phrase("", tcFont));                  //Col 0
            aTable.AddCell(new Phrase("TOTAL EMOLUMENTS", tHFont1)); //Col 2

            Cell A = new Cell(new Phrase(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:N0}", _ViewModel.TotalEmoluments), tHFont1));

            A.HorizontalAlignment = Cell.ALIGN_RIGHT;
            aTable.AddCell(A);                      //Col 3
            aTable.AddCell(new Phrase("", tcFont)); //Col 4

            //Row2
            Cell r2c1 = new Cell(new Phrase("", tcFont));

            r2c1.Rowspan = 2;
            aTable.AddCell(r2c1);                             //Col 0
            aTable.AddCell(new Phrase("TOTAL TAX", tHFont1)); //Col 2
            Cell r2c3 = new Cell(new Phrase("", tcFont));

            r2c3.Rowspan = 2;
            aTable.AddCell(r2c3);  //Col 3
            Cell B = new Cell(new Phrase(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:N0}", _ViewModel.TotalTaxDeducted), tHFont1));

            B.HorizontalAlignment = Cell.ALIGN_RIGHT;
            aTable.AddCell(B);//Col 4

            //Row3
            //aTable.AddCell(new Phrase("", tcFont));  //Col 0
            aTable.AddCell(new Phrase("TOTAL WCPS", tHFont1));  //Col 2
            //aTable.AddCell(new Phrase("", tcFont));  //Col 3
            Cell C = new Cell(new Phrase(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:N0}", _ViewModel.WCPS), tHFont1));

            C.HorizontalAlignment = Cell.ALIGN_RIGHT;
            aTable.AddCell(C);//Col 4

            //Row 4
            aTable.AddCell(new Phrase("", tcFont));  //Col 1
            Cell D = new Cell(new Phrase("*TAX ON LUMPSUM/AUDIT/INTEREST/PENALTY", tHFont1));

            D.Colspan = 2;

            aTable.AddCell(D);                      //Col 2
            aTable.AddCell(new Phrase("", tcFont)); //Col 3

            //Row 5
            aTable.AddCell(new Phrase("", tcFont));  //Col 1
            Cell E = new Cell(new Phrase("*TAX DEDUCTED / TOTAL C/F TO NEXT LIST", tHFont1));

            E.Colspan = 2;
            aTable.AddCell(E);                      //Col 2
            aTable.AddCell(new Phrase("", tcFont)); //Col 3
        }
Пример #26
0
        private Table InvoiceLinesTable(List <InvoiceLinesGroupDTO> posList, float posFontSize, bool isInvoiceCorrection = false)
        {
            var posListTable = new Table(UnitValue.CreatePercentArray(new float[] { 7, 1, 1, 1, 2, 2, 2, 2, 2 })); //cols: 9

            posListTable.AddCell(TableHeaderCell("Nazwa towaru/usługi", posFontSize * 0.8f, 1, 1));
            posListTable.AddCell(TableHeaderCell("PKWiU", posFontSize * 0.8f, 1, 1));
            posListTable.AddCell(TableHeaderCell("Ilość", posFontSize * 0.8f, 1, 1));
            posListTable.AddCell(TableHeaderCell("Jedn.", posFontSize * 0.8f, 1, 1));
            posListTable.AddCell(TableHeaderCell("Cena jednostkowa", posFontSize * 0.8f, 1, 1));
            posListTable.AddCell(TableHeaderCell("Wartość netto", posFontSize * 0.8f, 1, 1));
            posListTable.AddCell(TableHeaderCell("Stawka %", posFontSize * 0.8f, 1, 1));
            posListTable.AddCell(TableHeaderCell("Kwota podatku", posFontSize * 0.8f, 1, 1));
            posListTable.AddCell(TableHeaderCell("Wartość brutto", posFontSize * 0.8f, 1, 1));

            int lineNo = 1;

            foreach (var pos in posList)
            {
                var isCorr             = pos.Current.IsCorrected;
                var corrFontSize       = posFontSize * 0.8f;
                var corrHeaderFontSize = posFontSize * 0.9f;

                var posCurrent     = pos.Current;
                var posCorrections = pos.Corrections;
                var posOriginal    = pos.Original;

                var currName = $"{lineNo.ToString()}) {posCurrent.Name}";
                var orgName  = $"{lineNo.ToString()}) {posOriginal.Name}";


                //if Invoice line is corrected
                if (isCorr)
                {
                    posListTable.AddCell(FakCell("Przed korektą: ", null, corrHeaderFontSize, TextAlignment.LEFT, 1, 9));
                    posListTable.AddCell(PozCell(orgName, corrFontSize, TextAlignment.LEFT, 1, 1));
                    posListTable.AddCell(PozCell(posOriginal.Pkwiu, corrFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                    posListTable.AddCell(PozCell(posOriginal.Quantity.ToString(), corrFontSize, TextAlignment.CENTER, 1, 1));
                    posListTable.AddCell(PozCell(posOriginal.Measurement_unit, corrFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                    posListTable.AddCell(PozCell(posOriginal.Unit_price.ToString("# ##0.00"), corrFontSize, TextAlignment.RIGHT, 1, 1));
                    posListTable.AddCell(PozCell(posOriginal.Netto_value.ToString("# ##0.00"), corrFontSize, TextAlignment.RIGHT, 1, 1));
                    posListTable.AddCell(PozCell(posOriginal.Vat_rate, corrFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                    posListTable.AddCell(PozCell(posOriginal.Vat_value.ToString("# ##0.00"), corrFontSize, TextAlignment.RIGHT, 1, 1));
                    posListTable.AddCell(PozCell(posOriginal.Brutto_value.ToString("# ##0.00"), corrFontSize * 1.1f, TextAlignment.RIGHT, 1, 1));


                    //correction
                    posListTable.AddCell(FakCell("Korekta: ", null, corrHeaderFontSize, TextAlignment.LEFT, 1, 9)).SetKeepWithNext(true);
                    posListTable.AddCell(PozCell($"Przyczyna korekty: {posCurrent.CorrectionInfo}", corrFontSize, TextAlignment.LEFT, 1, 2));
                    posListTable.AddCell(PozCell(posCorrections.Quantity == 0 ? "-" : posCorrections.Quantity.ToString(), corrFontSize, TextAlignment.CENTER, 1, 1));
                    posListTable.AddCell(PozCell(posCorrections.Measurement_unit, corrFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                    posListTable.AddCell(PozCell(posCorrections.Unit_price == 0 ? "-" : posCorrections.Unit_price.ToString("# ##0.00"), corrFontSize, TextAlignment.RIGHT, 1, 1));
                    posListTable.AddCell(PozCell(posCorrections.Netto_value == 0 ? "-" : posCorrections.Netto_value.ToString("# ##0.00"), corrFontSize, TextAlignment.RIGHT, 1, 1));
                    posListTable.AddCell(PozCell(posCorrections.Vat_rate, corrFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                    posListTable.AddCell(PozCell(posCorrections.Vat_value == 0 ? "-" : posCorrections.Vat_value.ToString("# ##0.00"), corrFontSize, TextAlignment.RIGHT, 1, 1));
                    posListTable.AddCell(PozCell(posCorrections.Brutto_value == 0 ? "-" : posCorrections.Brutto_value.ToString("# ##0.00"), corrFontSize * 1.1f, TextAlignment.RIGHT, 1, 1));

                    //original
                }


                if (isInvoiceCorrection)
                {
                    if (isCorr)
                    {
                        posListTable.AddCell(FakCell("Po korekcie: ", null, corrHeaderFontSize, TextAlignment.LEFT, 1, 9));
                    }
                    else
                    {
                        posListTable.AddCell(FakCell("Bez zmian: ", null, corrHeaderFontSize, TextAlignment.LEFT, 1, 9));
                    }
                    posListTable.AddCell(PozCell(currName, posFontSize, TextAlignment.LEFT, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                    posListTable.AddCell(PozCell(posCurrent.Pkwiu, corrFontSize * 0.8f, TextAlignment.CENTER, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                    posListTable.AddCell(PozCell(posCurrent.Quantity.ToString(), posFontSize, TextAlignment.CENTER, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                    posListTable.AddCell(PozCell(posCurrent.Measurement_unit, posFontSize * 0.8f, TextAlignment.CENTER, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                    posListTable.AddCell(PozCell(posCurrent.Unit_price.ToString("# ##0.00"), posFontSize, TextAlignment.RIGHT, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                    posListTable.AddCell(PozCell(posCurrent.Netto_value.ToString("# ##0.00"), posFontSize, TextAlignment.RIGHT, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                    posListTable.AddCell(PozCell(posCurrent.Vat_rate, posFontSize * 0.8f, TextAlignment.CENTER, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                    posListTable.AddCell(PozCell(posCurrent.Vat_value > 0 ? posCurrent.Vat_value.ToString("# ##0.00") : "-", posFontSize, TextAlignment.RIGHT, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                    posListTable.AddCell(PozCell(posCurrent.Brutto_value.ToString("# ##0.00"), posFontSize * 1.1f, TextAlignment.RIGHT, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                }
                if (!isInvoiceCorrection)
                {
                    posListTable.AddCell(PozCell(currName, posFontSize, TextAlignment.LEFT, 1, 1));
                    posListTable.AddCell(PozCell(posCurrent.Pkwiu, corrFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                    posListTable.AddCell(PozCell(posCurrent.Quantity.ToString(), posFontSize, TextAlignment.CENTER, 1, 1));
                    posListTable.AddCell(PozCell(posCurrent.Measurement_unit, posFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                    posListTable.AddCell(PozCell(posCurrent.Unit_price.ToString("# ##0.00"), posFontSize, TextAlignment.RIGHT, 1, 1));
                    posListTable.AddCell(PozCell(posCurrent.Netto_value.ToString("# ##0.00"), posFontSize, TextAlignment.RIGHT, 1, 1));
                    posListTable.AddCell(PozCell(posCurrent.Vat_rate, posFontSize * 0.8f, TextAlignment.CENTER, 1, 1));
                    posListTable.AddCell(PozCell(posCurrent.Vat_value > 0 ? posCurrent.Vat_value.ToString("# ##0.00") : "-", posFontSize, TextAlignment.RIGHT, 1, 1));
                    posListTable.AddCell(PozCell(posCurrent.Brutto_value.ToString("# ##0.00"), posFontSize * 1.1f, TextAlignment.RIGHT, 1, 1));
                }
                lineNo++;
            }



            return(posListTable);
        }
Пример #27
0
        private MemoryStream ITEXTRender(DataTable dt, bool rtf)
        {
            Document document = new Document(PageSize.A4, 80, 50, 30, 65);

            document.AddAuthor("Tustena CRM");


            MemoryStream ms = new MemoryStream();

            if (rtf)
            {
                RtfWriter writerA = RtfWriter.GetInstance(document, ms);
            }
            else
            {
                PdfWriter writerA = PdfWriter.GetInstance(document, ms);
                writerA.ViewerPreferences = PdfWriter.PageLayoutSinglePage;
            }

            HeaderFooter header = new HeaderFooter(new Phrase("Tustena Report", FontFactory.GetFont(FontFactory.HELVETICA, 14, Font.BOLD)), false);
            HeaderFooter footer = new HeaderFooter(new Phrase("page ", FontFactory.GetFont(FontFactory.HELVETICA, 11)), true);

            document.Header = header;
            document.Footer = footer;
            document.Open();
            document.SetPageSize(PageSize.A4);
            Cell cell;

            if (dt.Rows.Count > 0)
            {
                Table table = new Table(dt.Columns.Count);
                table.TableFitsPage              = false;
                table.WidthPercentage            = 100;
                table.SpaceInsideCell            = 2;
                table.DefaultHorizontalAlignment = Element.ALIGN_LEFT;
                table.DefaultVerticalAlignment   = Element.ALIGN_MIDDLE;
                foreach (DataColumn cc in dt.Columns)
                {
                    string cellName = (cc.ColumnName.Substring(0, 3) == "{+}" || cc.ColumnName.Substring(0, 3) == "{t}") ? cc.ColumnName.Substring(3, cc.ColumnName.Length - 3) : cc.ColumnName;
                    cell = new Cell(cellName.ToString());
                    cell.BackgroundColor     = new Color(200, 200, 200);
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                    cell.Header = true;
                    table.AddCell(cell);
                }
                table.EndHeaders();
                double[] sum     = new double[dt.Columns.Count];
                bool[]   sumType = new bool[dt.Columns.Count];
                bool     boolSum = false;
                foreach (DataRow rowname in dt.Rows)
                {
                    int i        = 0;
                    int indexSum = 0;
                    foreach (DataColumn cc in dt.Columns)
                    {
                        if (cc.ColumnName.Substring(0, 3) == "{+}" || cc.ColumnName.Substring(0, 3) == "{t}")
                        {
                            sum[indexSum]    += Convert.ToDouble(rowname[cc.ColumnName]);
                            sumType[indexSum] = (cc.ColumnName.Substring(0, 3) == "{t}"); // true = tempo , false = numerico
                            boolSum           = true;
                        }
                        indexSum++;
                        string timeToPrint = String.Empty;
                        if (cc.ColumnName.Substring(0, 3) == "{t}")
                        {
                            int duration = Convert.ToInt32(rowname[cc.ColumnName]);
                            if (duration > 0)
                            {
                                if (duration < 60)
                                {
                                    timeToPrint = "00:" + ((duration > 9) ? duration.ToString() : "0" + duration.ToString());
                                }
                                else
                                {
                                    timeToPrint = ((Convert.ToInt32(duration / 60) > 9) ? Convert.ToInt32(duration / 60).ToString() : "0" + Convert.ToInt32(duration / 60).ToString()) + ":" +
                                                  ((Convert.ToInt32(duration % 60) > 9) ? Convert.ToInt32(duration % 60).ToString() : "0" + Convert.ToInt32(duration % 60).ToString());
                                }
                            }
                        }
                        if (cc.ColumnName.Substring(0, 3) == "{+}" || cc.ColumnName.Substring(0, 3) == "{t}")
                        {
                            if (cc.ColumnName.Substring(0, 3) == "{t}")
                            {
                                cell = new Cell(timeToPrint);
                            }
                            else
                            {
                                cell = new Cell(rowname[cc.ColumnName].ToString());
                            }
                        }
                        else
                        {
                            cell = new Cell(rowname[cc.ColumnName].ToString());
                        }
                        if ((i++ % 2) == 0)
                        {
                            cell.BackgroundColor = new Color(230, 230, 230);
                        }
                        table.AddCell(cell);
                    }
                }
                if (boolSum)
                {
                    for (int i = 0; i < sum.Length; i++)
                    {
                        if (sum[i] > 0)
                        {
                            if (sumType[i])
                            {
                                int    duration    = Convert.ToInt32(sum[i]);
                                string timeToPrint = String.Empty;
                                if (duration > 0)
                                {
                                    if (duration < 60)
                                    {
                                        timeToPrint = "00:" + ((duration > 9) ? duration.ToString() : "0" + duration.ToString());
                                    }
                                    else
                                    {
                                        timeToPrint = ((Convert.ToInt32(duration / 60) > 9) ? Convert.ToInt32(duration / 60).ToString() : "0" + Convert.ToInt32(duration / 60).ToString()) + ":" +
                                                      ((Convert.ToInt32(duration % 60) > 9) ? Convert.ToInt32(duration % 60).ToString() : "0" + Convert.ToInt32(duration % 60).ToString());
                                    }
                                }

                                cell = new Cell(timeToPrint);
                            }
                            else
                            {
                                cell = new Cell(sum[i].ToString());
                            }
                        }
                        else
                        {
                            cell = new Cell("");
                        }

                        cell.BackgroundColor = new Color(200, 200, 200);
                        table.AddCell(cell);
                    }
                }
                document.Add(table);
            }
            document.Close();
            return(ms);
        }
Пример #28
0
        private Table InvoiceRatesTable(List <InvoiceRatesGroupDTO> rates, float posFontSize, bool isCorrection = false)
        {
            var smallFontSize       = posFontSize * 0.75f;
            var rowSpan             = isCorrection ? 2 : 1;
            var tableWidth          = isCorrection ? 60 : 50;
            var tableCols           = new float[] { 1, 2, 2, 2 };
            var tableColsCorrection = new float[] { 1, 1, 2, 2, 2 };

            var tbl = new Table(UnitValue.CreatePercentArray(isCorrection ? tableColsCorrection : tableCols));

            tbl.SetWidth(UnitValue.CreatePercentValue(tableWidth));

            tbl.AddCell(TableHeaderCell("Stawka", posFontSize, 1, isCorrection ? 2 : 1));
            tbl.AddCell(TableHeaderCell("Netto", posFontSize, 1, 1));
            tbl.AddCell(TableHeaderCell("Podatek", posFontSize, 1, 1));
            tbl.AddCell(TableHeaderCell("Brutto", posFontSize, 1, 1));

            foreach (var taxpos in rates.OrderBy(o => o.Current.Vat_value))
            {
                var vatRate = string.IsNullOrEmpty(taxpos.Current.Vat_rate) ? taxpos.Original.Vat_rate : taxpos.Current.Vat_rate;
                if (isCorrection)
                {
                    tbl.AddCell(PozCell(vatRate, posFontSize, TextAlignment.CENTER, isCorrection ? 3 : 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                    tbl.AddCell(PozCell("przed korektą: ", smallFontSize * 0.7f, TextAlignment.CENTER, 1, 1));
                    tbl.AddCell(PozCell(taxpos.Original.Netto_value.ToString("# ##0.00"), smallFontSize, TextAlignment.CENTER, 1, 1));
                    tbl.AddCell(PozCell(taxpos.Original.Vat_value == 0 ? "-" : taxpos.Original.Vat_value.ToString("# ##0.00"), smallFontSize, TextAlignment.CENTER, 1, 1));
                    tbl.AddCell(PozCell(taxpos.Original.Brutto_value.ToString("# ##0.00"), smallFontSize, TextAlignment.CENTER, 1, 1));

                    tbl.AddCell(PozCell("korekta: ", smallFontSize * 0.7f, TextAlignment.CENTER, 1, 1));
                    tbl.AddCell(PozCell(taxpos.Corrections.Netto_value == 0 ? "-" : taxpos.Corrections.Netto_value.ToString("# ##0.00"), smallFontSize, TextAlignment.CENTER, 1, 1));
                    tbl.AddCell(PozCell(taxpos.Corrections.Vat_value == 0 ? "-" : taxpos.Corrections.Vat_value.ToString("# ##0.00"), smallFontSize, TextAlignment.CENTER, 1, 1));
                    tbl.AddCell(PozCell(taxpos.Corrections.Brutto_value == 0 ? "-" : taxpos.Corrections.Brutto_value.ToString("# ##0.00"), smallFontSize, TextAlignment.CENTER, 1, 1));

                    tbl.AddCell(PozCell("po korekcie: ", smallFontSize * 0.7f, TextAlignment.CENTER, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                    tbl.AddCell(PozCell(taxpos.Current.Netto_value.ToString("# ##0.00"), posFontSize, TextAlignment.CENTER, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                    tbl.AddCell(PozCell(taxpos.Current.Vat_value > 0 ? taxpos.Current.Vat_value.ToString("# ##0.00") : "-", posFontSize, TextAlignment.CENTER, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                    tbl.AddCell(PozCell(taxpos.Current.Brutto_value.ToString("# ##0.00"), posFontSize, TextAlignment.CENTER, 1, 1).SetBorderBottom(this.TableLineBottomBorder()));
                }
                else
                {
                    tbl.AddCell(PozCell(vatRate, posFontSize, TextAlignment.CENTER, isCorrection ? 3 : 1, 1));
                    tbl.AddCell(PozCell(taxpos.Current.Netto_value.ToString("# ##0.00"), posFontSize, TextAlignment.CENTER, 1, 1));
                    tbl.AddCell(PozCell(taxpos.Current.Vat_value > 0 ? taxpos.Current.Vat_value.ToString("# ##0.00") : "-", posFontSize, TextAlignment.CENTER, 1, 1));
                    tbl.AddCell(PozCell(taxpos.Current.Brutto_value.ToString("# ##0.00"), posFontSize, TextAlignment.CENTER, 1, 1));
                }
            }
            return(tbl);
        }
Пример #29
0
        //Creates the PDF report with the format
        void createPdfReport(string path)
        {
            using (var writer = new PdfWriter(path))
            {
                using (var pdf = new PdfDocument(writer))
                {
                    var doc = new Document(pdf, PageSize.A4);
                    //Header information
                    doc.Add(createParagraphWithTab("Name ", nameTextBox.Text));
                    doc.Add(createParagraphWithTab("Month ", monthComboBox.Text));
                    doc.Add(createParagraphWithTab("Vehicle Number ", vehicleNumberTextBox.Text));

                    doc.Add(new Paragraph());

                    //Table information
                    float[] pointColumnWidths = { 75f, 75f, 112.5f, 112.5f, 112.5f, 150f };
                    Table   table             = new Table(pointColumnWidths);

                    table.AddCell(new Cell().Add(new Paragraph("Date")).SetBackgroundColor(ColorConstants.LIGHT_GRAY));
                    table.AddCell(new Cell().Add(new Paragraph("Day")).SetBackgroundColor(ColorConstants.LIGHT_GRAY));
                    table.AddCell(new Cell().Add(new Paragraph("Start (km)")).SetBackgroundColor(ColorConstants.LIGHT_GRAY));
                    table.AddCell(new Cell().Add(new Paragraph("End (km)")).SetBackgroundColor(ColorConstants.LIGHT_GRAY));
                    table.AddCell(new Cell().Add(new Paragraph("Total (km)")).SetBackgroundColor(ColorConstants.LIGHT_GRAY));
                    table.AddCell(new Cell().Add(new Paragraph("Location Travelled")).SetBackgroundColor(ColorConstants.LIGHT_GRAY));

                    //Read all records from the list
                    foreach (Record r in displayedRecords)
                    {
                        table.AddCell(new Cell().Add(new Paragraph(r.date.ToShortDateString())));
                        table.AddCell(new Cell().Add(new Paragraph(r.day)));
                        table.AddCell(new Cell().Add(new Paragraph(r.startDistance.ToString())));
                        table.AddCell(new Cell().Add(new Paragraph(r.endDistance.ToString())));
                        table.AddCell(new Cell().Add(new Paragraph(r.totalDistance.ToString())));
                        table.AddCell(new Cell().Add(new Paragraph(r.locationTravelled)));
                    }
                    Console.WriteLine("I can run");


                    doc.Add(table);
                }
            }
        }
Пример #30
0
        public void SimpleRowColspan()
        {
            FileStream fs = new FileStream(string.Format(@"pdf\{0}__SimpleRowColspan_{1:yyyyMMddhhmmss}.pdf", ClassName, DateTime.Now), FileMode.Create);

            PdfDocument pdfDoc = new PdfDocument(new PdfWriter(fs));
            Document    doc    = new Document(pdfDoc);

            Table table = new Table(UnitValue.CreatePercentArray(new float[] { 1, 2, 2, 2, 1 }));

            Cell cell = new Cell(2, 1).Add(new Paragraph("S/N"));

            table.AddCell(cell);

            cell = new Cell(1, 3).Add(new Paragraph("Name"));
            table.AddCell(cell);

            cell = new Cell(2, 1).Add(new Paragraph("Age"));
            table.AddCell(cell);

            table.AddCell("SURNAME");
            table.AddCell("FIRST NAME");
            table.AddCell("MIDDLE NAME");
            table.AddCell("1");
            table.AddCell("James");
            table.AddCell("Fish");
            table.AddCell("Stone");
            table.AddCell("17");

            doc.Add(table);

            doc.Close();
        }