當前位置: 首頁>>代碼示例>>C#>>正文


C# PdfPTable.CompleteRow方法代碼示例

本文整理匯總了C#中iTextSharp.text.pdf.PdfPTable.CompleteRow方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfPTable.CompleteRow方法的具體用法?C# PdfPTable.CompleteRow怎麽用?C# PdfPTable.CompleteRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.text.pdf.PdfPTable的用法示例。


在下文中一共展示了PdfPTable.CompleteRow方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GenerarDocumento

 public void GenerarDocumento(Document document)
 {
     int i, j;
     PdfPTable datatable = new PdfPTable(dataGridView1.ColumnCount);
     datatable.DefaultCell.Padding = 3;
     float[] headerwidths = GetTamañoColumnas(dataGridView1);
     datatable.SetWidths(headerwidths);
     datatable.WidthPercentage = 100;
     datatable.DefaultCell.BorderWidth = 2;
     datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
     for (i = 0; i < dataGridView1.ColumnCount; i++)
     {
         datatable.AddCell(dataGridView1.Columns[i].HeaderText);
     }
     datatable.HeaderRows = 1;
     datatable.DefaultCell.BorderWidth = 1;
     for (i = 0; i < dataGridView1.Rows.Count; i++)
     {
         for (j = 0; j < dataGridView1.Columns.Count; j++)
         {
             if (dataGridView1[j, i].Value != null)
             {
                 datatable.AddCell(new Phrase(dataGridView1[j, i].Value.ToString()));//En esta parte, se esta agregando un renglon por cada registro en el datagrid
             }
         }
         datatable.CompleteRow();
     }
     document.Add(datatable);
 }
開發者ID:Warrior6021,項目名稱:ReportesItextSharp,代碼行數:29,代碼來源:Form1.cs

示例2: MakeCards

        public void MakeCards()
        {
            var deck = JsonConvert.DeserializeObject<Deck>(File.ReadAllText(@"C:\temp\testdeck.cm"));

            var cards = new List<MagickImage>();
            foreach (var card in deck.Cards) {
                var image = new MagickImage(new MagickColor("WhiteSmoke"), deck.Width, deck.Height);
                image.Density = new MagickGeometry(300, 300);
                image.Format = MagickFormat.Bmp;
                foreach (var element in deck.Elements) {
                    var data = card.ElementData[element.Key];
                    if (File.Exists(data)) {
                        using (var overlayImage = new MagickImage(data)) {
                            image.Composite(overlayImage, (int)element.Value.X, (int)element.Value.Y, CompositeOperator.Over);
                        }
                    } else {
                        using (var textImage = new MagickImage(MagickColor.Transparent, deck.Width, deck.Height)) {
                            textImage.Density = new MagickGeometry(300, 300);
                            textImage.Font = "Arial";
                            textImage.FontPointsize = 12;
                            textImage.FillColor = new MagickColor("Black");
                            var drawableText = new DrawableText(element.Value.X, element.Value.Y, data);
                            textImage.Draw(drawableText);
                            image.Composite(textImage, CompositeOperator.Over);
                        }
                    }
                }
                image.Write(string.Format(@"c:\temp\CardMaker\{0}.png", card.Name));
                cards.Add(image);

            }
            using (var doc = new Document()) {
                PdfWriter.GetInstance(doc, new FileStream(@"C:\temp\CardMaker\cards.pdf", FileMode.Create));
                doc.Open();
                var columns = (int)Math.Floor(doc.PageSize.Width / (deck.Width + 10));
                var table = new PdfPTable(columns) { WidthPercentage = 100, DefaultCell = { Border = 0, Padding = 5 } };

                foreach (var card in cards) {
                    var instance = Image.GetInstance(card.ToByteArray());
                    instance.SetDpi(300, 300);
                    var cell = new PdfPCell(instance) {
                        HorizontalAlignment = Element.ALIGN_CENTER,
                        Border = 0,
                        Padding = 5,
                    };
                    table.AddCell(cell);
                }
                table.CompleteRow();
                doc.Add(table);
            }
        }
開發者ID:camwheeler,項目名稱:CardMaker,代碼行數:51,代碼來源:CardGenerator.cs

示例3: Write

 // ===========================================================================
 public void Write(Stream stream)
 {
     // step 1
     using (Document document = new Document())
     {
         // step 2
         PdfWriter.GetInstance(document, stream);
         // step 3
         document.Open();
         // step 4
         string RESOURCE = Utility.ResourcePosters;
         // we'll use 4 images in this example
         Image[] img = {
             Image.GetInstance(Path.Combine(RESOURCE, "0120903.jpg")),
             Image.GetInstance(Path.Combine(RESOURCE, "0290334.jpg")),
             Image.GetInstance(Path.Combine(RESOURCE, "0376994.jpg")),
             Image.GetInstance(Path.Combine(RESOURCE, "0348150.jpg"))
         };
         // Creates a table with 6 columns
         PdfPTable table = new PdfPTable(6);
         table.WidthPercentage = 100;
         // first movie
         table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
         table.DefaultCell.VerticalAlignment = Element.ALIGN_TOP;
         table.AddCell("X-Men");
         // we wrap he image in a PdfPCell
         PdfPCell cell = new PdfPCell(img[0]);
         table.AddCell(cell);
         // second movie
         table.DefaultCell.VerticalAlignment = Element.ALIGN_MIDDLE;
         table.AddCell("X2");
         // we wrap the image in a PdfPCell and let iText scale it
         cell = new PdfPCell(img[1], true);
         table.AddCell(cell);
         // third movie
         table.DefaultCell.VerticalAlignment = Element.ALIGN_BOTTOM;
         table.AddCell("X-Men: The Last Stand");
         // we add the image with addCell()
         table.AddCell(img[2]);
         // fourth movie
         table.AddCell("Superman Returns");
         cell = new PdfPCell();
         // we add it with addElement(); it can only take 50% of the width.
         img[3].WidthPercentage = 50;
         cell.AddElement(img[3]);
         table.AddCell(cell);
         // we complete the table (otherwise the last row won't be rendered)
         table.CompleteRow();
         document.Add(table);
     }
 }
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:52,代碼來源:XMen.cs

示例4: AddEmptyRow

 private void AddEmptyRow(PdfPTable pdfPTable)
 {
     var columns = pdfPTable.NumberOfColumns;
     PdfPCell[] rowCells = new PdfPCell[columns];
     for (int j = 0; j < columns; j++)
     {
         rowCells[j] = new PdfPCell((new Phrase(" ", PDFBuilder.DefaultFont)))
         {
             PaddingLeft = 4,
             PaddingRight = 4,
             UseBorderPadding = true
         };
     }
     pdfPTable.Rows.Add(new PdfPRow(rowCells));
     pdfPTable.CompleteRow();
 }
開發者ID:Dason1986,項目名稱:Lib,代碼行數:16,代碼來源:PDFTableBuilder.cs

示例5: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;
            var q = DbUtil.Db.PeopleQuery(id);
            var q2 = from p in q
                     orderby p.Name2
                     select new
                     {
                         First = p.PreferredName,
                         Last = p.LastName,
                         p.PeopleId,
                         dob = p.DOB,
                         Phone = p.CellPhone.Length > 0 ? p.CellPhone : p.HomePhone,
                         p.DoNotPublishPhones
                     };
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "filename=foo.pdf");

            var document = new Document(PageSize.LETTER);
            document.SetMargins(40f, 36f, 32f, 36f);
            var w = PdfWriter.GetInstance(document, Response.OutputStream);
            document.Open();
            dc = w.DirectContent;

            var cols = new float[] { W, W, W - 10f };
            var t = new PdfPTable(cols);
            t.SetTotalWidth(cols);

            t.HorizontalAlignment = Element.ALIGN_CENTER;
            t.LockedWidth = true;
            t.DefaultCell.Border = PdfPCell.NO_BORDER;

            if (!q2.Any())
                document.Add(new Phrase("no data"));
            else
                foreach (var m in q2)
                    AddCell(t, m.First, m.Last, m.Phone, m.PeopleId, m.DoNotPublishPhones);
            t.CompleteRow();
            document.Add(t);

            document.Close();
        }
開發者ID:stevesloka,項目名稱:bvcms,代碼行數:42,代碼來源:AveryResult.cs

示例6: ExportarPDFPlanificacion

        /// <summary>
        /// Exportars the PDF planificacion.
        /// </summary>
        /// <param name="TituloInforme">The titulo informe.</param>
        /// <param name="objPlanificacion">The obj planificacion.</param>
        public static void ExportarPDFPlanificacion(string TituloInforme, PlanificacionAnual objPlanificacion)
        {
            itsEvents ev = new itsEvents();

            Document documento = new Document(PageSize.A4, 10, 10, 80, 50);
            PdfWriter writerPdf = PdfWriter.GetInstance(documento, HttpContext.Current.Response.OutputStream);
            writerPdf.PageEvent = ev;
            documento.Open();

            string strTitulo = "Asignatura: " + objPlanificacion.curricula.asignatura.nombre
                          + "\n " + objPlanificacion.cicloLectivo.nombre.Substring(0, 13) + ": "
                          + objPlanificacion.cicloLectivo.nombre.Substring(14);

            string strFileName = "Planificacion_" + objPlanificacion.curricula.asignatura.nombre
                          + "_" + objPlanificacion.curricula.nivel.nombre;

            string fecha = DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0');

            Font font24B = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 24, Font.BOLD, BaseColor.GRAY);
            Phrase Titulo = new Phrase("[email protected] 2.0", font24B);

            Font font15B = FontFactory.GetFont(FontFactory.HELVETICA, 15, Font.BOLD);
            ev.tituloReporte = TituloInforme;
            ev.fechaReporte = fecha;

            Font font12 = FontFactory.GetFont(FontFactory.TIMES, 12, Font.NORMAL);

            Paragraph parrafo = new Paragraph(strTitulo, font15B);
            documento.Add(parrafo);

            if (objPlanificacion.listaCursos != null && objPlanificacion.listaCursos.Count > 0)
            {
                parrafo = new Paragraph("Cursos: ", font15B);
                documento.Add(parrafo);
                foreach (CursoCicloLectivo item in objPlanificacion.listaCursos)
                {
                    parrafo = new Paragraph("- " + objPlanificacion.curricula.nivel.nombre + " " + item.curso.nombre, font15B);
                    documento.Add(parrafo);
                }
            }

            string strFechas;
            if (objPlanificacion.fechaAprobada.HasValue)
            {
                strFechas = "Fecha Aprobación: " + Convert.ToDateTime(objPlanificacion.fechaAprobada).ToShortDateString();
                parrafo = new Paragraph(strFechas, font15B);
                documento.Add(parrafo);
            }
            else
            {
                Font font15R = FontFactory.GetFont(FontFactory.HELVETICA, 15, Font.BOLDITALIC, BaseColor.RED);
                strFechas = "Pendiente de Aprobación";
                parrafo = new Paragraph(strFechas, font15R);
                documento.Add(parrafo);
            }

            PdfPTable tabla = new PdfPTable(1);
            tabla.SpacingBefore = 10;
            tabla.SpacingAfter = 0;
            tabla.KeepTogether = true;
            tabla.WidthPercentage = 100;
            PdfPCell celdaTitulo = new PdfPCell(new Phrase("", font15B));
            celdaTitulo.Border = 0;
            celdaTitulo.BorderWidthBottom = 1;
            tabla.AddCell(celdaTitulo);
            tabla.CompleteRow();
            documento.Add(tabla);

            //parrafo = new Paragraph("\n", font15B);
            //documento.Add(parrafo);

            if (objPlanificacion.listaTemasPlanificacion.Count > 0)
            {
                int contador = 0;
                foreach (TemaPlanificacionAnual item in objPlanificacion.listaTemasPlanificacion)
                {
                    contador++;
                    parrafo = new Paragraph("Periodo: " + Convert.ToDateTime(item.fechaInicioEstimada).ToShortDateString() + " al " + Convert.ToDateTime(item.fechaFinEstimada).ToShortDateString(), font15B);
                    documento.Add(parrafo);

                    if (item.contenidosConceptuales.Trim().Length > 0)
                    {
                        parrafo = new Paragraph("Contenidos Conceptuales", font15B);
                        documento.Add(parrafo);

                        parrafo = new Paragraph(item.contenidosConceptuales, font12);
                        documento.Add(parrafo);

                        parrafo = new Paragraph("\n", font15B);
                        documento.Add(parrafo);
                    }

                    if (item.contenidosActitudinales.Trim().Length > 0)
                    {
                        parrafo = new Paragraph("Contenidos Actitudinales", font15B);
//.........這裏部分代碼省略.........
開發者ID:martinherr3,項目名稱:blpm,代碼行數:101,代碼來源:ExportPDF.cs

示例7: ExportarGraficoPDF

        /// <summary>
        /// Exportars the grafico PDF.
        /// </summary>
        /// <param name="TituloInforme">The titulo informe.</param>
        /// <param name="username">The username.</param>
        /// <param name="filtros">The filtros.</param>
        /// <param name="nombrePNG">The nombre PNG.</param>
        /// <param name="tablaGrafico">The tabla grafico.</param>
        public static void ExportarGraficoPDF(string TituloInforme, string username, string filtros, string nombrePNG, List<string> tablaGrafico)
        {
            itsEvents ev = new itsEvents();

            Persona usuario = new Persona();
            usuario.username = username;
            BLPersona objBLPersona = new BLPersona(usuario);
            objBLPersona.GetPersonaByEntidad();
            usuario = objBLPersona.Data;

            Document documento = new Document(PageSize.A4, 10, 10, 80, 50);
            PdfWriter writerPdf = PdfWriter.GetInstance(documento, HttpContext.Current.Response.OutputStream);
            writerPdf.PageEvent = ev;
            documento.Open();

            string strTitulo = TituloInforme;
            string fecha = DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0');

            Font font24B = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 24, Font.BOLD, BaseColor.GRAY);
            Phrase Titulo = new Phrase("[email protected] 2.0", font24B);

            Font font15B = FontFactory.GetFont(FontFactory.HELVETICA, 15, Font.BOLDITALIC);
            ev.tituloReporte = strTitulo;
            ev.fechaReporte = fecha;

            Font font12B = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12, Font.NORMAL);
            Font font10N = FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.NORMAL);
            PdfPTable grdTableEncabezado = new PdfPTable(1);
            grdTableEncabezado.WidthPercentage = 90;
            grdTableEncabezado.AddCell(new PdfPCell(new Phrase("- Usuario: " + usuario.apellido + " " + usuario.nombre, font12B)));
            grdTableEncabezado.CompleteRow();
            grdTableEncabezado.AddCell(new PdfPCell(new Phrase(filtros, font12B)));
            grdTableEncabezado.CompleteRow();
            documento.Add(grdTableEncabezado);

            //valido si mando el nombre de un gráfico
            if (!string.IsNullOrEmpty(nombrePNG))
            {
                //Verifica si existe el archivo
                if (System.IO.File.Exists(nombrePNG))
                {
                    documento.Add(new Paragraph(""));
                    Image grafico = Image.GetInstance(nombrePNG);
                    grafico.ScalePercent(50, 50);
                    grafico.Alignment = Element.ALIGN_CENTER;
                    if (grafico != null)
                        documento.Add(grafico);
                    documento.Add(new Paragraph(""));
                }
            }

            // Recorremos la variable tablaGrafico para agregar información adicional a la exportación del gráfico
            foreach (var item in tablaGrafico)
            {
                if (item.Substring(0, 1).Equals("-"))
                    documento.Add(new iTextSharp.text.Paragraph(item, font12B));
                else
                    documento.Add(new iTextSharp.text.Paragraph(item, font10N));
            }

            //Cerramos el Documento
            documento.Close();
            strTitulo = strTitulo.Replace(" ", string.Empty);
            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + strTitulo.Trim().Replace(" ", string.Empty) + "-" + fecha.Replace(' ', '_').Trim() + ".pdf");
            HttpContext.Current.Response.Flush();
        }
開發者ID:martinherr3,項目名稱:blpm,代碼行數:75,代碼來源:ExportPDF.cs

示例8: ExportarPDF

        /// <summary>
        /// Exportars the PDF.
        /// </summary>
        /// <param name="TituloPagina">The titulo pagina.</param>
        /// <param name="dtReporte">The dt reporte.</param>
        /// <param name="username">The username.</param>
        /// <param name="filtros">The filtros.</param>
        /// <param name="nombrePNG">The nombre PNG.</param>
        public static void ExportarPDF(string TituloInforme, DataTable dtReporte, string username, string filtros, string nombrePNG)
        {
            itsEvents ev = new itsEvents();

            Persona usuario = new Persona();
            usuario.username = username;
            BLPersona objBLPersona = new BLPersona(usuario);
            objBLPersona.GetPersonaByEntidad();
            usuario = objBLPersona.Data;

            int columnCount = dtReporte.Columns.Count;
            int rowCount = dtReporte.Rows.Count;

            Document documento = new Document(PageSize.A4, 10, 10, 80, 50);
            PdfWriter writerPdf = PdfWriter.GetInstance(documento, HttpContext.Current.Response.OutputStream);
            writerPdf.PageEvent = ev;
            documento.Open();

            string strTitulo = TituloInforme;
            string fecha = DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour.ToString().PadLeft(2, '0') + ":" + DateTime.Now.Minute.ToString().PadLeft(2, '0');

            Font font24B = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 24, Font.BOLD, BaseColor.GRAY);
            Phrase Titulo = new Phrase("[email protected] 2.0", font24B);

            Font font15B = FontFactory.GetFont(FontFactory.HELVETICA, 15, Font.BOLDITALIC);
            ev.tituloReporte = strTitulo;
            ev.fechaReporte = fecha;

            Font font12B = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12, Font.NORMAL);
            PdfPTable grdTableEncabezado = new PdfPTable(1);
            grdTableEncabezado.WidthPercentage = 90;
            grdTableEncabezado.AddCell(new PdfPCell(new Phrase("- Usuario: " + usuario.apellido + " " + usuario.nombre, font12B)));
            grdTableEncabezado.CompleteRow();
            grdTableEncabezado.AddCell(new PdfPCell(new Phrase(filtros, font12B)));
            grdTableEncabezado.CompleteRow();
            documento.Add(grdTableEncabezado);

            //valido si mando el nombre de un gráfico
            if (!string.IsNullOrEmpty(nombrePNG))
            {
                //Verifica si existe el archivo
                if (System.IO.File.Exists(nombrePNG))
                {
                    string TmpPath = System.Configuration.ConfigurationManager.AppSettings["oTmpPath"];

                    documento.Add(new Paragraph(""));
                    Image grafico = Image.GetInstance(nombrePNG);
                    grafico.ScalePercent(50, 50);
                    grafico.Alignment = Element.ALIGN_CENTER;
                    if (grafico != null)
                        documento.Add(grafico);
                    documento.Add(new Paragraph(""));
                }
            }

            PdfPTable grdTable = new PdfPTable(columnCount);
            Font LetraTituloTabla = FontFactory.GetFont(FontFactory.HELVETICA, 9, Font.BOLDITALIC, BaseColor.BLUE);
            float[] espacios = new float[columnCount];
            for (int i = 0; i < columnCount; i++)
            {
                espacios[i] = 80 / columnCount;
            }

            grdTable.SetWidths(espacios);
            grdTable.WidthPercentage = 90;

            //Creamos las cabeceras de la tabla
            //Adicionamos las cabeceras a la tabla
            foreach (DataColumn columna in dtReporte.Columns)
            {
                grdTable.AddCell(new PdfPCell(new Phrase(columna.ColumnName.ToUpperInvariant(), LetraTituloTabla)));
            }

            Font LetraDefecto = FontFactory.GetFont(FontFactory.HELVETICA, 8, Font.NORMAL);

            grdTable.CompleteRow();

            grdTable.HeaderRows = 1;

            foreach (DataRow fila in dtReporte.Rows)
            {
                for (int i = 0; i < columnCount; i++)
                {
                    string dato = fila[i].ToString();
                    if (fila[i].GetType().Name == "DateTime")
                        dato = Convert.ToDateTime(fila[i].ToString()).ToShortDateString();
                    grdTable.AddCell(new Phrase(HttpUtility.HtmlDecode(dato), LetraDefecto));
                }
                grdTable.CompleteRow();
            }

            //Cerramos el Documento
//.........這裏部分代碼省略.........
開發者ID:martinherr3,項目名稱:blpm,代碼行數:101,代碼來源:ExportPDF.cs

示例9: Write

 // ---------------------------------------------------------------------------
 /**
  * Creates a PDF document.
  */
 public virtual void Write(Stream stream)
 {
     // step 1
     using (Document document = new Document(PageSize.A4.Rotate()))
     {
         // step 2
         PdfWriter writer = PdfWriter.GetInstance(document, stream);
         // step 3
         document.Open();
         // step 4
         // "en" => System.Globalization.GregorianCalendar 
         Calendar calendar = new CultureInfo(LANGUAGE, false).Calendar;
         PdfContentByte canvas = writer.DirectContent;
         // Loop over the months
         for (int month = 0; month < 12; month++)
         {
             int current_month = month + 1;
             DateTime dt = new DateTime(YEAR, current_month, 1, calendar);
             // draw the background
             DrawImageAndText(canvas, dt);
             // create a table with 7 columns
             PdfPTable table = new PdfPTable(7);
             table.TotalWidth = 504;
             // add the name of the month
             table.DefaultCell.BackgroundColor = BaseColor.WHITE;
             table.AddCell(GetMonthCell(dt));
             int daysInMonth = DateTime.DaysInMonth(YEAR, dt.Month);
             int day = 1;
             // add empty cells
             // SUNDAY; Java => 1, .NET => 0
             int position = 0;
             while (position++ != (int)dt.DayOfWeek)
             {
                 table.AddCell("");
             }
             // add cells for each day
             while (day <= daysInMonth)
             {
                 dt = new DateTime(YEAR, current_month, day++, calendar);
                 table.AddCell(GetDayCell(dt));
             }
             // complete the table
             table.CompleteRow();
             // write the table to an absolute position
             table.WriteSelectedRows(0, -1, 169, table.TotalHeight + 18, canvas);
             document.NewPage();
         }
     }
 }
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:53,代碼來源:PdfCalendar.cs

示例10: BuilBodyData

        private void BuilBodyData(PdfPTable pdfPTable)
        {
            DataManager manager = new DataManager(table.DataSource) { NameIgnoreCase = true };

            int columns = table.Heads.Length;

            var indexs = new int[columns];
            for (int i = 0; i < columns; i++)
            {
                var col = table.Heads[i];
                indexs[i] = manager.GetOrdinal(col.BindName);
            }

            for (int i = 0; i < manager.Count; i++)
            {
                manager.Position = i;
                PdfPCell[] rowCells = new PdfPCell[columns];
                int j = 0;
                foreach (var i1 in indexs)
                {
                    var cel = ObjectUtility.Cast<string>(manager.GetValue(i1));

                    rowCells[j] = new PdfPCell((new Phrase(string.IsNullOrEmpty(cel) ? " " : cel, PDFBuilder.DefaultFont)))
                    {
                        PaddingLeft = 4,
                        PaddingRight = 4,
                        UseBorderPadding = true
                    };
                    j++;
                }

                pdfPTable.Rows.Add(new PdfPRow(rowCells));
                pdfPTable.CompleteRow();
            }
            if (!table.FillRows) return;
            var count = table.FillRowCounts - manager.Count;
            if (count > 0)
            {
                FillTabel(count, pdfPTable);
            }
        }
開發者ID:Dason1986,項目名稱:Lib,代碼行數:41,代碼來源:PDFTableBuilder.cs

示例11: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "filename=foo.pdf");

            dt = Util.Now;

            doc = new Document(PageSize.LETTER, 36, 36, 36, 36);
            var w = PdfWriter.GetInstance(doc, Response.OutputStream);
            w.PageEvent = pageEvents;
            doc.Open();
            dc = w.DirectContent;
            ct = new ColumnText(dc);

            if (!qid.HasValue)
                doc.Add(new Phrase("no data"));
            else
            {
                pageEvents.StartPageSet("Outreach/Inreach Report: {0:d}".Fmt(dt));
                IQueryable<ProspectInfo> q = GetProspectInfo(AlphaSort);
                if (!q.Any())
                    doc.Add(new Phrase("no data"));
                else
                    foreach (var p in q)
                    {
                        doc.NewPage();
                        var t = new PdfPTable(new float[] { 62f, 61f, 67f });
                        t.SetNoPadding();
                        var t1 = new PdfPTable(1);
                        t1.SetNoBorder();
                        var t2 = new PdfPTable(new float[] { 30f, 31f });
                        t2.SetNoBorder();
                        var t3 = new PdfPTable(new float[] { 27f, 40f });
                        t3.SetNoBorder();

                        var ph = new Paragraph();
                        ph.Add(new Chunk(p.Name, bfont));
                        ph.Add(new Chunk(" ({0})".Fmt(p.PeopleId), smallfont));
                        t1.AddCell(ph);
                        ph = new Paragraph();
                        ph.AddLine(p.Address, font);
                        ph.AddLine(p.Address2, font);
                        ph.AddLine(p.CityStateZip, font);
                        ph.Add("\n");
                        ph.AddLine(p.HomePhone.FmtFone("H"), font);
                        ph.AddLine(p.CellPhone.FmtFone("C"), font);
                        ph.AddLine(p.EMail, font);
                        t1.AddCell(ph);
                        t.AddCell(t1);

                        t2.Add("Position in Family:", font);
                        t2.Add(p.PositionInFamily, font);
                        t2.Add("Gender:", font);
                        t2.Add(p.Gender, font);
                        t2.Add("Marital Status:", font);
                        t2.Add(p.MaritalStatus, font);
                        t2.Add("", font);
                        t2.CompleteRow();

                        if (p.ChristAsSavior.HasValue())
                            t2.Add(p.ChristAsSavior, 2, font);
                        if (p.InfoBecomeAChristian.HasValue())
                            t2.Add(p.InfoBecomeAChristian, 2, font);
                        if (p.InterestedInJoining.HasValue())
                            t2.Add(p.InterestedInJoining, 2, font);
                        if (p.PleaseVisit.HasValue())
                            t2.Add(p.PleaseVisit, 2, font);

                        t.AddCell(t2);

                        t3.Add("Member Status:", font);
                        t3.Add(p.MemberStatus, font);
                        t3.Add("Origin:", font);
                        t3.Add(p.Origin, font);
                        t3.Add("Age:", font);
                        t3.Add(p.Age, font);
                        t3.Add("Comments:", 2, font);
                        t3.Add(p.Comment, 2, font);

                        t.AddCell(t3);
                        doc.Add(t);

                        if (p.Family.Count() > 0)
                        {
                            t = new PdfPTable(5);
                            t.SetNoBorder();
                            t.AddRow("Family Summary", bfont);
                            t.AddHeader("Name", bfont);
                            t.AddHeader("Age", bfont);
                            t.AddHeader("Cell Phone", bfont);
                            t.AddHeader("Position in Family", bfont);
                            t.AddHeader("Member Status", bfont);
                            foreach (var fm in p.Family)
                            {
                                t.Add(fm.Name, font);
                                t.Add(fm.Age.ToString(), font);
                                t.Add(fm.CellPhone.FmtFone(), font);
                                t.Add(fm.PositionInFamily, font);
                                t.Add(fm.MemberStatus, font);
//.........這裏部分代碼省略.........
開發者ID:rossspoon,項目名稱:bvcms,代碼行數:101,代碼來源:ProspectResult.cs

示例12: CreatePDFDocument

        public static void CreatePDFDocument()
        {
            var document = new Document();
            //string path = Server.MapPath("PDFs");
            PdfWriter.GetInstance(document, new FileStream("../../document.pdf", FileMode.Create));
            document.Open();
            PdfPTable table = new PdfPTable(5);


            //leave a gap before and after the table
            table.SpacingBefore = 20f;
            table.SpacingAfter = 30f;

            using (var db = new CatalogContext())
            {

                //one query to the database
                var sales = db.Sales
                    .Include("Product")
                    .Include("Shop")
                    .OrderBy(x => new { x.Date, x.ProductID, x.ShopID })
                    .ToList();
                DateTime reportDate = new DateTime();
                decimal totalSum = 0;
                foreach (var sale in sales)
                {
                    if (reportDate != sale.Date)
                    {
                        if (totalSum != 0)
                        {
                            table.AddCell("");
                            table.AddCell("");
                            table.AddCell("");
                            table.AddCell(string.Format("Total sum for: {0}", reportDate.ToString("dd-MMM-yyyy")));
                            //PdfPCell total = new PdfPCell(new Phrase(string.Format("Total: {0}", totalSum)));
                            //total.HorizontalAlignment = 1;
                            //total.Colspan = 4;

                            //table.AddCell(total);
                            table.AddCell(string.Format("Total: {0}", totalSum));
                            totalSum = 0;
                        }
                        table.AddCell(string.Format("Date: {0}", sale.Date.ToString("dd-MMM-yyyy")));
                        table.CompleteRow();
                        table.AddCell("Product");
                        table.AddCell("Quantity");
                        table.AddCell("UnitPrice");
                        table.AddCell("Location");
                        table.AddCell("Sum");
                        reportDate = sale.Date;
                    }
                    totalSum += sale.Sum;
                    table.AddCell(sale.Product.ProductName);
                    table.AddCell(sale.Quantity.ToString());
                    table.AddCell(sale.UnitPrice.ToString());
                    table.AddCell(sale.Shop.Name);
                    table.AddCell(sale.Sum.ToString());
                }

                document.Add(table);
                document.Close();
            }
        }
開發者ID:nnaidenov,項目名稱:TelerikAcademy,代碼行數:63,代碼來源:PDFGeneratorClient.cs

示例13: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "filename=foo.pdf");

            dt = Util.Now;

            doc = new Document(PageSize.LETTER.Rotate(), 36, 36, 64, 64);
            var w = PdfWriter.GetInstance(doc, Response.OutputStream);

            var i = (from m in DbUtil.Db.Meetings
                     where m.MeetingId == mtgid
                     select new
                     {
                         m.Organization.OrganizationName,
                         m.Organization.LeaderName,
                         m.MeetingDate
                     }).SingleOrDefault();

            w.PageEvent = new HeadFoot
            {
                HeaderText = $"Guests/Absents Report: {i.OrganizationName} - {i.LeaderName} {i.MeetingDate:g}",
                FooterText = "Guests/Absents Report"
            };
            doc.Open();

            var q = VisitsAbsents(mtgid.Value);

            if (!mtgid.HasValue || i == null || !q.Any())
                doc.Add(new Paragraph("no data"));
            else
            {
                var mt = new PdfPTable(1);
                mt.SetNoPadding();
                mt.HeaderRows = 1;

                float[] widths = {4f, 6f, 7f, 2.6f, 2f, 3f};
                var t = new PdfPTable(widths);
                t.DefaultCell.Border = Rectangle.NO_BORDER;
                t.DefaultCell.VerticalAlignment = Element.ALIGN_TOP;
                t.DefaultCell.SetLeading(2.0f, 1f);
                t.WidthPercentage = 100;

                t.AddHeader("Name", boldfont);
                t.AddHeader("Address", boldfont);
                t.AddHeader("Phone/Email", boldfont);
                t.AddHeader("Last Att.", boldfont);
                t.AddHeader("Birthday", boldfont);
                t.AddHeader("Guest/Member", boldfont);
                mt.AddCell(t);

                var color = BaseColor.BLACK;
                bool? v = null;
                foreach (var p in q)
                {
                    if (color == BaseColor.WHITE)
                        color = new GrayColor(240);
                    else
                        color = BaseColor.WHITE;

                    t = new PdfPTable(widths);
                    t.SetNoBorder();
                    t.DefaultCell.VerticalAlignment = Element.ALIGN_TOP;
                    t.DefaultCell.BackgroundColor = color;

                    if (v != p.visitor)
                        t.Add($"             ------ {(p.visitor ? "Guests" : "Absentees")} ------", 6, bigboldfont);
                    v = p.visitor;

                    t.Add(p.Name, font);

                    var ph = new Paragraph();
                    ph.AddLine(p.Address, font);
                    ph.AddLine(p.Address2, font);
                    ph.AddLine(p.CSZ, font);
                    t.AddCell(ph);

                    ph = new Paragraph();
                    ph.AddLine(p.HomePhone.FmtFone("H"), font);
                    ph.AddLine(p.CellPhone.FmtFone("C"), font);
                    ph.AddLine(p.Email, font);
                    t.AddCell(ph);

                    t.Add(p.LastAttend.FormatDate(), font);
                    t.Add(p.Birthday, font);
                    t.Add(p.Status, font);
                    t.CompleteRow();

                    if (p.Status == null || !p.Status.StartsWith("Visit"))
                    {
                        t.Add("", font);
                        t.Add($"{p.AttendStr}           {p.AttendPct:n1}{(p.AttendPct.HasValue ? "%" : "")}", 5, monofont);
                    }

                    mt.AddCell(t);
                }
                doc.Add(mt);
            }
            doc.Close();
//.........這裏部分代碼省略.........
開發者ID:stevesloka,項目名稱:bvcms,代碼行數:101,代碼來源:VisitsAbsentsResult.cs

示例14: End


//.........這裏部分代碼省略.........
                        for (int column = 0; column < columnWidths.Length; column++) {
                            if (fixedWidths[column] == 0) {
                                columnWidths[column] *= targetPercentage;
                            }
                        }
                    }
                }
                try {
                    table.SetTotalWidth(columnWidths);
                    table.LockedWidth = true;
                    table.DefaultCell.Border = Rectangle.NO_BORDER;
                } catch (DocumentException e) {
                    throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e);
                }
                float? tableHeight = new HeightCalculator().GetHeight(tag, GetHtmlPipelineContext(ctx).PageSize.Height);
                float? tableRowHeight = null;
                if (tableHeight != null && tableHeight > 0)
                    tableRowHeight = tableHeight / tableRows.Count;
                int rowNumber = 0;
                foreach (TableRowElement row in tableRows) {
                    int columnNumber = -1;
                    float? computedRowHeight = null;
                    /*if ( tableHeight != null &&  tableRows.IndexOf(row) == tableRows.Count - 1) {
                        float computedTableHeigt = table.CalculateHeights();
                        computedRowHeight = tableHeight - computedTableHeigt;
                    }*/
                    IList<HtmlCell> rowContent = row.Content;
                    if(rowContent.Count < 1)
                        continue;
                    foreach (HtmlCell cell in rowContent) {
                        IList<IElement> compositeElements = cell.CompositeElements;
                        if (compositeElements != null) {
                            foreach (IElement baseLevel in compositeElements) {
                                if (baseLevel is PdfPTable) {
                                    TableStyleValues cellValues = cell.CellValues;
                                    float totalBordersWidth = cellValues.IsLastInRow ? styleValues.HorBorderSpacing * 2
                                            : styleValues.HorBorderSpacing;
                                    totalBordersWidth += cellValues.BorderWidthLeft + cellValues.BorderWidthRight;
                                    float columnWidth = 0;
                                    for (int currentColumnNumber = columnNumber + 1; currentColumnNumber <= columnNumber + cell.Colspan; currentColumnNumber++){
                                        columnWidth += columnWidths[currentColumnNumber];
                                    }
                                    IPdfPTableEvent tableEvent = ((PdfPTable) baseLevel).TableEvent;
                                    TableStyleValues innerStyleValues = ((TableBorderEvent) tableEvent).TableStyleValues;
                                    totalBordersWidth += innerStyleValues.BorderWidthLeft;
                                    totalBordersWidth += innerStyleValues.BorderWidthRight;
                                    ((PdfPTable) baseLevel).TotalWidth = columnWidth - totalBordersWidth;
                                }
                            }
                        }
                        columnNumber += cell.Colspan;

                        table.AddCell(cell);
                    }
                    table.CompleteRow();
                    if ((computedRowHeight == null || computedRowHeight <= 0) && tableRowHeight != null)
                        computedRowHeight = tableRowHeight;
                    if (computedRowHeight != null && computedRowHeight > 0) {
                        float rowHeight = table.GetRow(rowNumber).MaxHeights;
                        if (rowHeight < computedRowHeight) {
                            table.GetRow(rowNumber).MaxHeights = computedRowHeight.Value;
                        }
                        else if (tableRowHeight != null && tableRowHeight < rowHeight)
                        {
                            tableRowHeight = (tableHeight - rowHeight - rowNumber * tableRowHeight)
                                    / (tableRows.Count - rowNumber - 1);
                        }
                    }
                    rowNumber++;
                }
                if (percentage) {
				    table.WidthPercentage = utils.ParsePxInCmMmPcToPt(widthValue);
				    table.LockedWidth = false;
			    }
                List<IElement> elems = new List<IElement>();
                if (invalidRowElements.Count > 0) {
                    // all invalid row elements taken as caption
                    int i = 0;
                    Tag captionTag = tag.Children[i++];
                    while (!Util.EqualsIgnoreCase(captionTag.Name, HTML.Tag.CAPTION) && i < tag.Children.Count) {
                        captionTag = tag.Children[i];
                        i++;
                    }
                    String captionSideValue;
                    captionTag.CSS.TryGetValue(CSS.Property.CAPTION_SIDE, out captionSideValue);
                    if (captionSideValue != null && Util.EqualsIgnoreCase(captionSideValue, CSS.Value.BOTTOM)) {
                        elems.Add(table);
                        elems.AddRange(invalidRowElements);
                    } else {
                        elems.AddRange(invalidRowElements);
                        elems.Add(table);
                    }
                } else {
                    elems.Add(table);
                }
                return elems;
            } catch (NoCustomContextException e) {
                throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e);
            }
        }
開發者ID:jagruti23,項目名稱:itextsharp,代碼行數:101,代碼來源:Table.cs

示例15: CreatePDFReport

        private static void CreatePDFReport(Dictionary<DateTime, List<DayReport>> sales)
        {
            //creating the document and setting the path
            var doc = new Document();
            doc.AddTitle("PDF Sales Report");
            string path = "../../PDFReports";
            PdfWriter.GetInstance(doc, new FileStream(path + "\\report.pdf", FileMode.Create));
            PdfPTable table = new PdfPTable(5);

            PdfPCell cell = new PdfPCell();
            PdfPCell firstCell = new PdfPCell();
            firstCell.PaddingLeft = 133;
            firstCell.Phrase = new Phrase("Aggregated Sales Report");
            firstCell.Colspan = 5;
            firstCell.BackgroundColor = new iTextSharp.text.Color(System.Drawing.Color.Aquamarine);
            table.AddCell(firstCell);
            firstCell.PaddingLeft = 2;
            table.CompleteRow();

            foreach (var saleByDate in sales)
            {
                firstCell.Phrase = new Phrase("Date: " + saleByDate.Key.ToShortDateString());
                table.AddCell(firstCell);
                table.CompleteRow();
                cell.BackgroundColor = new iTextSharp.text.Color(System.Drawing.Color.Aquamarine);
                Font boldFont = new Font();
                boldFont.Size = 18;
                cell.Phrase = new Phrase("Product", boldFont);
                table.AddCell(cell);
                cell.Phrase = new Phrase("Quantity", boldFont);
                table.AddCell(cell);
                cell.Phrase = new Phrase("Unit Price", boldFont);
                table.AddCell(cell);
                cell.Phrase = new Phrase("Location", boldFont);
                table.AddCell(cell);
                cell.Phrase = new Phrase("Sum", boldFont);
                table.AddCell(cell);
                cell.BackgroundColor = new iTextSharp.text.Color(System.Drawing.Color.White);
                var reportsByDay = sales[saleByDate.Key];
                double totalSum = 0;
                foreach (var item in reportsByDay)
                {
                    cell.Phrase = new Phrase(item.ProductName);
                    table.AddCell(cell);
                    cell.Phrase = new Phrase(item.Quantity);
                    table.AddCell(cell);
                    cell.Phrase = new Phrase(item.UnitPrice.ToString());
                    table.AddCell(cell);
                    cell.Phrase = new Phrase(item.MarketName);
                    table.AddCell(cell);
                    cell.Phrase = new Phrase(item.Sum.ToString());
                    table.AddCell(cell);
                    totalSum += item.Sum;
                }
                PdfPCell finalCell = new PdfPCell();
                finalCell.Colspan = 4;
                finalCell.Phrase = new Phrase("Total sum for " + saleByDate.Key.ToShortDateString() + ":");
                finalCell.PaddingLeft = 200;
                table.AddCell(finalCell);
                finalCell.Colspan = 1;
                finalCell.PaddingLeft = 1;
                boldFont.Size = 15;
                finalCell.Phrase = new Phrase(totalSum.ToString(),boldFont);
                table.AddCell(finalCell);
            }
                
            doc.Open();
            doc.Add(table);
            doc.Close();
        }
開發者ID:krstan4o,項目名稱:TelerikAcademy,代碼行數:70,代碼來源:Program.cs


注:本文中的iTextSharp.text.pdf.PdfPTable.CompleteRow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。