Пример #1
0
        /// <summary>
        /// Converts the specified table.
        /// </summary>
        /// <param name="table">The table.</param>
        /// <returns>The PDF table.</returns>
        public iTextSharp.text.pdf.PdfPTable Convert(Table table)
        {
            try
            {
                iTextSharp.text.pdf.PdfPTable pdfTable;
                TableLayoutInfo tableLayout = new TableLayoutInfo();
                tableLayout.AnalyzeTableLayout(table);

                if (tableLayout.CellWidths != null)
                {
                    pdfTable = new iTextSharp.text.pdf.PdfPTable(tableLayout.CellWidths);
                }
                else
                {
                    pdfTable = new iTextSharp.text.pdf.PdfPTable(tableLayout.MaxCells);
                }

                if (table.Style != null &&
                    table.Style is TableStyle &&
                    ((TableStyle)table.Style).TableProperties != null)
                {
                    //((TableStyle)table.Style).TableProperties.Width
                }

                foreach (Row row in table.Rows)
                {
                    foreach (Cell cell in row.Cells)
                    {
                        iTextSharp.text.pdf.PdfPCell pdfCell = new iTextSharp.text.pdf.PdfPCell();

                        if (cell.ColumnRepeating != null && Int32.Parse(cell.ColumnRepeating) > 0)
                        {
                            pdfCell.Colspan = Int32.Parse(cell.ColumnRepeating);
                        }

                        foreach (iTextSharp.text.IElement pdfElement in MixedContentConverter.GetMixedPdfContent(cell.Content))
                        {
                            pdfCell.AddElement(pdfElement);
                        }
                        pdfTable.AddCell(pdfCell);
                    }
                }

                //pdfTable = this.SetProperties(table, pdfTable, maxCells);

                return(pdfTable);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
 /// <summary>
 /// Converts the specified frame into an PDF paragraph.
 /// </summary>
 /// <param name="frame">The frame.</param>
 /// <returns>The paragraph representing the passed frame.</returns>
 public iTextSharp.text.Paragraph Convert(Frame frame)
 {
     try
     {
         iTextSharp.text.Paragraph paragraph = new iTextSharp.text.Paragraph();
         foreach (iTextSharp.text.IElement pdfElement in MixedContentConverter.GetMixedPdfContent(frame.Content))
         {
             paragraph.Add(pdfElement);
         }
         return(paragraph);
     }
     catch (Exception)
     {
         throw;
     }
 }