AODL.ExternalExporter.PDF.Document.ContentConverter.TableConverter.Convert C# (CSharp) Method

Convert() public method

Converts the specified table.
public Convert ( Table table ) : iTextSharp.text.pdf.PdfPTable
table AODL.Document.Content.Tables.Table The table.
return iTextSharp.text.pdf.PdfPTable
		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;
			}
		}

Usage Example

Example #1
0
 /// <summary>
 /// Convert a AODL IContentCollection into an ArrayList of IElement iText objects.
 /// </summary>
 /// <param name="iContentCollection">The i content collection.</param>
 /// <returns>An ArrayList of iText IElement objects.</returns>
 public static ArrayList GetMixedPdfContent(IContentCollection iContentCollection)
 {
     try
     {
         ArrayList mixedPdfContent = new ArrayList();
         foreach (IContent content in iContentCollection)
         {
             if (content is AODL.Document.Content.Text.Paragraph)
             {
                 if (((AODL.Document.Content.Text.Paragraph)content).MixedContent != null &&
                     ((AODL.Document.Content.Text.Paragraph)content).MixedContent.Count > 0)
                 {
                     mixedPdfContent.Add(ParagraphConverter.Convert(
                                             content as AODL.Document.Content.Text.Paragraph));
                 }
                 else
                 {
                     mixedPdfContent.Add(iTextSharp.text.Chunk.NEWLINE);
                 }
             }
             else if (content is AODL.Document.Content.Text.Header)
             {
                 mixedPdfContent.Add(HeadingConverter.Convert(
                                         content as AODL.Document.Content.Text.Header));
             }
             else if (content is AODL.Document.Content.Tables.Table)
             {
                 TableConverter tc = new TableConverter();
                 mixedPdfContent.Add(tc.Convert(
                                         content as AODL.Document.Content.Tables.Table));
             }
             else if (content is AODL.Document.Content.Draw.Frame)
             {
                 DrawFrameConverter dfc = new DrawFrameConverter();
                 mixedPdfContent.Add(dfc.Convert(
                                         content as AODL.Document.Content.Draw.Frame));
             }
             else if (content is AODL.Document.Content.Draw.Graphic)
             {
                 ImageConverter ic = new ImageConverter();
                 mixedPdfContent.Add(ic.Convert(
                                         content as AODL.Document.Content.Draw.Graphic));
             }
         }
         return(mixedPdfContent);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
All Usage Examples Of AODL.ExternalExporter.PDF.Document.ContentConverter.TableConverter::Convert