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


C# PdfPCell.AddElement方法代碼示例

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


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

示例1: GetTable

// ---------------------------------------------------------------------------    
    /**
     * Creates a table with screenings.
     * @param day a film festival day
     * @return a table with screenings
     */
    public PdfPTable GetTable(string day) {
    // Create a table with 7 columns
      PdfPTable table = new PdfPTable(new float[] { 2, 1, 2, 5, 1, 3, 2 });
      table.WidthPercentage = 100f;
      table.DefaultCell.UseAscender = true;
      table.DefaultCell.UseDescender = true;
      // Add the first header row
      Font f = new Font();
      f.Color = BaseColor.WHITE;
      PdfPCell cell = new PdfPCell(new Phrase(day, f));
      cell.BackgroundColor = BaseColor.BLACK;
      cell.HorizontalAlignment = Element.ALIGN_CENTER;
      cell.Colspan = 7;
      table.AddCell(cell);
      // Add the second header row twice
      table.DefaultCell.BackgroundColor = BaseColor.LIGHT_GRAY;
      for (int i = 0; i < 2; i++) {
        table.AddCell("Location");
        table.AddCell("Time");
        table.AddCell("Run Length");
        table.AddCell("Title");
        table.AddCell("Year");
        table.AddCell("Directors");
        table.AddCell("Countries");
      }
      table.DefaultCell.BackgroundColor = null;
      // There are three special rows
      table.HeaderRows = 3;
      // One of them is a footer
      table.FooterRows = 1;
      // Now let's loop over the screenings
      List<Screening> screenings = PojoFactory.GetScreenings(day);
      Movie movie;
      foreach (Screening screening in screenings) {
        movie = screening.movie;
        table.AddCell(screening.Location);
        table.AddCell(screening.Time.Substring(0, 5));
        table.AddCell(movie.Duration.ToString() + " '");
        table.AddCell(movie.MovieTitle);
        table.AddCell(movie.Year.ToString());
        cell = new PdfPCell();
        cell.UseAscender = true;
        cell.UseDescender = true;
        cell.AddElement(PojoToElementFactory.GetDirectorList(movie));
        table.AddCell(cell);
        cell = new PdfPCell();
        cell.UseAscender = true;
        cell.UseDescender = true;
        cell.AddElement(PojoToElementFactory.GetCountryList(movie));
        table.AddCell(cell);
      }
      return table;
    }    
開發者ID:,項目名稱:,代碼行數:59,代碼來源:

示例2: agregarIntimacionAdministrativaEncabezado

        private static void agregarIntimacionAdministrativaEncabezado(Document doc)
        {
            PdfPTable t = new PdfPTable(1);
            float[] widths = new float[] { 80f };
            t.WidthPercentage = 85;
            t.SetWidths(widths);
            int leading = 8;
            Paragraph p;
            PdfPCell c = new PdfPCell();

            c = new PdfPCell();
            c.Border = 0;
            c.PaddingTop = -2;
            c.Border = 0;
            c.BorderWidthBottom = 0;
            p = new Paragraph(leading, "CALVAGNA Consorcios - Maipú 1148 piso 10 Oficina 04 S2000CGN Rosario", calibri8I);
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.PaddingTop = -2;
            c.Border = 0;
            c.BorderWidthBottom = 0;
            p = new Paragraph(leading, "Certificada plegada sin sobre con aviso de retorno. Copia en poder del remitente", calibri8I);
            c.AddElement(p);
            t.AddCell(c);

            c = new PdfPCell();
            c.Border = 0;
            c.PaddingTop = -2;
            c.Border = 0;
            c.BorderWidthBottom = 0;
            p = new Paragraph(leading, "INTIMACION  ADMINISTRATIVA - ULTIMO AVISO PREVIO A LEGALES", calibri8I);
            c.AddElement(p);
            t.AddCell(c);

            doc.Add(t);
        }
開發者ID:fedec93,項目名稱:Administracion,代碼行數:39,代碼來源:Program.cs

示例3: GetFormattedCell

        private static PDF.PdfPCell GetFormattedCell(TableCell cell)
        {
            PDF.PdfPCell formattedCell = new PDF.PdfPCell();

            Element[] cellElements = cell.SubElements;

            foreach (Element temp in cellElements)
            {
                switch (temp.GetElementType())
                {
                    //TODO: Add other enum values
                    case ElementType.Text:
                        IT.Phrase phrase = new IT.Phrase(TextFormatter.GetFormattedText((Text)temp));
                        formattedCell.AddElement(phrase);
                        break;

                    case ElementType.Paragraph:
                        formattedCell.AddElement(ParagraphFormatter.GetFormattedParagraph((Paragraph)temp));
                        break;

                    case ElementType.Table:
                        formattedCell.AddElement(TableFormatter.GetFormattedTable((Table)temp));
                        break;

                    case ElementType.Image:
                        formattedCell.AddElement(ImageFormatter.GetFormattedImage((Image)temp));
                        break;
                }

            }

            return formattedCell;
        }
開發者ID:amilasurendra,項目名稱:pdf-generator,代碼行數:33,代碼來源:TableFormatter.cs

示例4: CreateNestedTables

        private static PdfPTable CreateNestedTables(int n) {
            PdfPCell cell = new PdfPCell();
            cell.AddElement(new Chunk("Hello"));

            if (n > 0)
                cell.AddElement(CreateNestedTables(n - 1));

            PdfPTable table = new PdfPTable(1);
            table.AddCell(cell);
            return table;
        }
開發者ID:newlysoft,項目名稱:itextsharp,代碼行數:11,代碼來源:NestedTablesTest.cs

示例5: RenderingCell

        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var pdfCell = new PdfPCell();
            var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR };

            var filePath = System.IO.Path.Combine(AppPath.ApplicationPath, "Images\\" + _rnd.Next(1, 5).ToString("00") + ".png");
            var photo = PdfImageHelper.GetITextSharpImageFromImageFile(filePath);
            table.AddCell(new PdfPCell(photo, fit: false)
            {
                Border = 0,
                VerticalAlignment = Element.ALIGN_BOTTOM,
                HorizontalAlignment = Element.ALIGN_CENTER
            });

            var name = attributes.RowData.TableRowData.GetSafeStringValueOf("User");
            table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(name))
            {
                Border = 0,
                HorizontalAlignment = Element.ALIGN_CENTER
            });

            pdfCell.AddElement(table);

            return pdfCell;
        }
開發者ID:andycarmona,項目名稱:TimelyDepotUps,代碼行數:25,代碼來源:MyCustomCellTemplate.cs

示例6: AddPlainRow

 public static void AddPlainRow(this PdfPTable t, string s, Font bfont)
 {
     var c = new PdfPCell(t.DefaultCell);
     c.Border = PdfPCell.NO_BORDER;
     c.Colspan = t.NumberOfColumns;
     c.AddElement(new Phrase(s, bfont));
     t.AddCell(c);
 }
開發者ID:rossspoon,項目名稱:bvcms,代碼行數:8,代碼來源:TableUtil.cs

示例7: Add

 public static void Add(this PdfPTable t, string s, int colspan, Font font)
 {
     var c = new PdfPCell(new Paragraph(s, font));
     c.Border = t.DefaultCell.Border;
     c.BackgroundColor = t.DefaultCell.BackgroundColor;
     c.SetLeading(t.DefaultCell.Leading, 1f);
     c.Colspan = colspan;
     c.AddElement(new Paragraph(s, font));
     t.AddCell(c);
 }
開發者ID:rossspoon,項目名稱:bvcms,代碼行數:10,代碼來源:TableUtil.cs

示例8: CreateMoviePage

        // ---------------------------------------------------------------------------
        /**
         * Creates the PDF.
         * @return the bytes of a PDF file.
         */
        public byte[] CreateMoviePage(Movie movie)
        {
            using (MemoryStream ms = new MemoryStream()) {
            // step 1
            using (Document document = new Document()) {
              // step 2
              PdfWriter.GetInstance(document, ms);
              // step 3
              document.Open();
              // step 4
              Paragraph p = new Paragraph(
            movie.MovieTitle,
            FontFactory.GetFont(
              BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED, 16
            )
              );
              document.Add(p);
              document.Add(Chunk.NEWLINE);
              PdfPTable table = new PdfPTable(WIDTHS);
              table.AddCell(Image.GetInstance(
            String.Format(RESOURCE, movie.Imdb)
              ));
              PdfPCell cell = new PdfPCell();
              cell.AddElement(new Paragraph("Year: " + movie.Year.ToString()));
              cell.AddElement(new Paragraph("Duration: " + movie.Duration.ToString()));
              table.AddCell(cell);
              document.Add(table);

              PdfTargetDictionary target = new PdfTargetDictionary(false);
              target.AdditionalPath = new PdfTargetDictionary(false);
              Chunk chunk = new Chunk("Go to original document");
              PdfAction action = PdfAction.GotoEmbedded(
            null, target, new PdfString("movies"), false
              );
              chunk.SetAction(action);
              document.Add(chunk);
            }
            return ms.ToArray();
              }
        }
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:45,代碼來源:KubrickMovies.cs

示例9: 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

示例10: AddRow

 public static void AddRow(this PdfPTable t, string s, Font bfont)
 {
     t.AddCell("");
     t.CompleteRow();
     var c = new PdfPCell(t.DefaultCell);
     c.Border = PdfPCell.TOP_BORDER;
     c.BorderColorTop = BaseColor.BLACK;
     c.BorderWidthTop = 2.0f;
     c.Colspan = t.NumberOfColumns;
     c.AddElement(new Paragraph(s, bfont));
     c.GrayFill = .8f;
     t.AddCell(c);
     c.MinimumHeight = t.DefaultCell.MinimumHeight;
 }
開發者ID:stevesloka,項目名稱:bvcms,代碼行數:14,代碼來源:TableUtil.cs

示例11: GeneratePdfElement

        public override iTextSharp.text.IElement GeneratePdfElement()
        {
            PdfPanelStyle style = (Manifest != null) ? Manifest.Styles.GetMergedFromConfiguration(Style) : Style;

            iTextPdf.PdfPTable panel = new iTextPdf.PdfPTable(1)
            {
                HorizontalAlignment = (int)(style.HorizontalAlignment ?? PdfPanelStyle.Default.HorizontalAlignment.Value),
                SpacingBefore = style.TopIndent ?? PdfPanelStyle.Default.TopIndent.Value,
                SpacingAfter = style.BottomIndent ?? PdfPanelStyle.Default.BottomIndent.Value,
            };

            iTextPdf.PdfPCell cell = new iTextPdf.PdfPCell()
            {
                BackgroundColor = new BaseColor(style.BackgroundColor ?? PdfPanelStyle.Default.BackgroundColor.Value),
                BorderColor = new BaseColor(style.BorderColor ?? PdfPanelStyle.Default.BorderColor.Value),
                Border = iText.Rectangle.BOX,
                Padding = style.Padding ?? PdfPanelStyle.Default.Padding.Value,
                BorderWidth = style.BorderWidth ?? PdfPanelStyle.Default.BorderWidth.Value,
            };

            if (Content.Any())
            {
                Content.ForEach(e => cell.AddElement(e.GeneratePdfElement()));
            }

            panel.AddCell(cell);

            cell.SetLeading(style.Leading ?? PdfPanelStyle.Default.Leading.Value, 0);

            if (style.Width.HasValue && !style.Width.Value.IsBlank)
            {
                PdfUnit unit = style.Width.Value;
                if (unit.Type.IsPercentage())
                {
                    panel.WidthPercentage = unit.Value;
                }
                else
                {
                    panel.SetTotalWidth(new float[] { unit.Value });
                    panel.LockedWidth= true;
                }
            }

            return panel;
        }
開發者ID:onesimoh,項目名稱:Andamio,代碼行數:45,代碼來源:PdfPanel.cs

示例12: RenderingCell

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var pdfCell = new PdfPCell();
            var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR };

            var photo = PdfImageHelper.GetITextSharpImageFromImageFile(System.IO.Path.Combine(AppPath.ApplicationPath, "Images\\" + _rnd.Next(1, 5).ToString("00") + ".png"));
            table.AddCell(new PdfPCell(photo) { Border = 0, MinimumHeight = photo.Height, VerticalAlignment = Element.ALIGN_BOTTOM });

            var name = attributes.RowData.TableRowData.GetSafeStringValueOf<User>(x => x.Name);
            table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(name)) { Border = 0 });

            var lastName = attributes.RowData.TableRowData.GetSafeStringValueOf<User>(x => x.LastName);
            table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(lastName)) { Border = 0 });

            pdfCell.AddElement(table);

            return pdfCell;
        }
開發者ID:VahidN,項目名稱:PdfReport,代碼行數:22,代碼來源:MailingLabelCellTemplate.cs

示例13: GetTable

 // ---------------------------------------------------------------------------   
 /**
  * Create a table with information about a movie.
  * @param screening a Screening
  * @return a table
  */
 private PdfPTable GetTable(Screening screening)
 {
     // Create a table with 4 columns
     PdfPTable table = new PdfPTable(4);
     table.SetWidths(new int[] { 1, 5, 10, 10 });
     // Get the movie
     Movie movie = screening.movie;
     // A cell with the title as a nested table spanning the complete row
     PdfPCell cell = new PdfPCell();
     // nesting is done with addElement() in this example
     cell.AddElement(FullTitle(screening));
     cell.Colspan = 4;
     cell.Border = PdfPCell.NO_BORDER;
     BaseColor color = WebColors.GetRGBColor(
       "#" + movie.entry.category.color
     );
     cell.BackgroundColor = color;
     table.AddCell(cell);
     // empty cell
     cell = new PdfPCell();
     cell.Border = PdfPCell.NO_BORDER;
     cell.UseAscender = true;
     cell.UseDescender = true;
     table.AddCell(cell);
     // cell with the movie poster
     cell = new PdfPCell(GetImage(movie.Imdb));
     cell.Border = PdfPCell.NO_BORDER;
     table.AddCell(cell);
     // cell with the list of directors
     cell = new PdfPCell();
     cell.AddElement(PojoToElementFactory.GetDirectorList(movie));
     cell.Border = PdfPCell.NO_BORDER;
     cell.UseAscender = true;
     cell.UseDescender = true;
     table.AddCell(cell);
     // cell with the list of countries
     cell = new PdfPCell();
     cell.AddElement(PojoToElementFactory.GetCountryList(movie));
     cell.Border = PdfPCell.NO_BORDER;
     cell.UseAscender = true;
     cell.UseDescender = true;
     table.AddCell(cell);
     return table;
 }
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:50,代碼來源:NestedTables.cs

示例14: RenderingCell

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var pdfCell = new PdfPCell();
            var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR };

            // Please note that All columns and properties of an object will create a single cell here.

            var idx = attributes.RowData.ColumnNumber;
            var data = attributes.RowData.TableRowData;

            var character = data.GetSafeStringValueOf<CharacterInfo>(x => x.Character, propertyIndex: idx);
            table.AddCell(new PdfPCell(_customFont.FontSelector.Process(character)) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });

            var characterCode = data.GetSafeStringValueOf<CharacterInfo>(x => x.CharacterCode, propertyIndex: idx);
            table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(characterCode)) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });

            pdfCell.AddElement(table);

            return pdfCell;
        }
開發者ID:andycarmona,項目名稱:TimelyDepotUps,代碼行數:24,代碼來源:CellTemplate.cs

示例15: AddCellToTable

        private static void AddCellToTable(PdfPTable table, string text, Func<byte[]> converter)
        {
            Image image = Image.GetInstance(converter());
            PdfPCell cell = new PdfPCell();

            cell.AddElement(new Paragraph(text));
            cell.AddElement(new Chunk("\n"));
            cell.AddElement(image);

            table.AddCell(cell);
        }
開發者ID:blake2002,項目名稱:DatabaseBenchmark,代碼行數:11,代碼來源:PdfUtils.cs


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