// --------------------------------------------------------------------------- /** * Creates a table that mimics cellspacing using table and cell events. * @param connection * @return a table * @throws SQLException * @throws DocumentException * @throws IOException */ public PdfPTable GetTable() { PdfPTable table = new PdfPTable(new float[] { 1, 2, 2, 5, 1 }); table.TableEvent = new PressPreviews(); table.WidthPercentage = 100f; table.DefaultCell.Padding = 5; table.DefaultCell.Border = PdfPCell.NO_BORDER; table.DefaultCell.CellEvent = new PressPreviews(); for (int i = 0; i < 2; i++) { table.AddCell("Location"); table.AddCell("Date/Time"); table.AddCell("Run Length"); table.AddCell("Title"); table.AddCell("Year"); } table.DefaultCell.BackgroundColor = null; table.HeaderRows = 2; table.FooterRows = 1; List <Screening> screenings = PojoFactory.GetPressPreviews(); foreach (Screening screening in screenings) { Movie movie = screening.movie; table.AddCell(screening.Location); table.AddCell(String.Format( "{0} {1}", screening.Date, screening.Time.Substring(0, 5) )); table.AddCell(String.Format("{0} '", movie.Duration)); table.AddCell(movie.MovieTitle); table.AddCell(movie.Year.ToString()); } return(table); }