private static void CreateDataTable(IList <Document> documents) { var table = new PdfPTable(7); table.SetWidths(new float[] { 165, 165, 165, 165, 165, 165, 165 }); _pdfDocument.AddCell(table, "Document Type"); _pdfDocument.AddCell(table, "Expiration"); _pdfDocument.AddCell(table, "Registration Number"); _pdfDocument.AddCell(table, "Technician"); _pdfDocument.AddCell(table, "Customer"); _pdfDocument.AddCell(table, "Vehicle Manufacturer"); _pdfDocument.AddCell(table, "Invoice Number"); for (int j = 1; j < 19; j++) { if (j < documents.Count + 1) { Document document = documents[j - 1]; AddCell(table, document.GetType().Name.SplitByCapitals()); AddCell(table, document.Created.AddYears(2).ToString(Constants.DateFormat)); AddCell(table, document.RegistrationNumber); AddCell(table, document.Technician); AddCell(table, document.CustomerContact); var tachographDocument = document as TachographDocument; if (tachographDocument != null) { AddCell(table, tachographDocument.VehicleMake); AddCell(table, tachographDocument.InvoiceNumber); } else { AddCell(table, string.Empty); AddCell(table, string.Empty); } } else { for (int i = 0; i < 11; i++) { AddCell(table, String.Empty); } } } table.TotalWidth = 520; table.WriteSelectedRows(0, -1, _pdfDocument.Document.LeftMargin + 10, _pdfDocument.Height - 160, _pdfDocument.ContentByte); }