public CSVData ProcessCSV(string fullPath) { using (TextFieldParser parser = new TextFieldParser(fullPath)) { CSVData data = new CSVData() { FileName = fullPath }; parser.SetDelimiters(new string[] { "," }); //skip headers parser.ReadLine(); while (!parser.EndOfData) { string[] fields = parser.ReadFields(); List <string> inputImages = new List <string>(); string[] imagePaths = fields[7].Split(new char[] { '|' }); inputImages.AddRange(imagePaths); InputRow row = new InputRow() { PdfOut = fields[0], Bookmark = fields[1], HeaderFooterMetadata = "Lot Number:" + fields[2] + " Part Number:" + fields[4], XmlFile = fields[3], ItemNumber = fields[4], LotNumber = fields[5], CertType = fields[6], InputPDFs = inputImages }; data.InputRows.Add(row); } return(data); } }
private void AddHeaderAndFooter(CSVData csvData, InputRow row, Document doc, System.Drawing.Image image) { string headerFooterString = row.HeaderFooterMetadata; var pageSize = doc.PageSize; PdfPTable table = new PdfPTable(3); table.WidthPercentage = 100; var fontRegular = FontFactory.GetFont("Arial", 7); if (csvData.HeaderLeft) { AddTextCell(table, headerFooterString, fontRegular, PdfPCell.ALIGN_LEFT); } else { AddEmptyCell(table); } if (csvData.HeaderCenter) { AddTextCell(table, headerFooterString, fontRegular); } else { AddEmptyCell(table); } if (csvData.HeaderRight) { AddTextCell(table, headerFooterString, fontRegular, PdfPCell.ALIGN_RIGHT); } else { AddEmptyCell(table); } doc.Add(table); table = new PdfPTable(1); table.WidthPercentage = 100; PdfPCell rightCell = new PdfPCell(new iTextSharp.text.Phrase("CERTIFIED TRUE COPY of Document held by Wencor QA", fontRegular)); rightCell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; rightCell.Border = 0; table.AddCell(rightCell); doc.Add(table); table = new PdfPTable(1); table.DefaultCell.Border = 0; table.WidthPercentage = 100; var imageCell = Image.GetInstance(image, (BaseColor)null); //imageCell.SpacingAfter = 50; table.AddCell(imageCell); table.SpacingAfter = 20; table.SpacingBefore = 20; doc.Add(table); table = new PdfPTable(1); table.WidthPercentage = 100; rightCell = new PdfPCell(new iTextSharp.text.Phrase("CERTIFIED TRUE COPY of Document held by Wencor QA", fontRegular)); rightCell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; rightCell.Border = 0; table.AddCell(rightCell); doc.Add(table); table = new PdfPTable(3); table.WidthPercentage = 100; if (csvData.FooterLeft) { AddTextCell(table, headerFooterString, fontRegular, PdfPCell.ALIGN_LEFT); } else { AddEmptyCell(table); } if (csvData.FooterCenter) { AddTextCell(table, headerFooterString, fontRegular); } else { AddEmptyCell(table); } if (csvData.FooterRight) { AddTextCell(table, headerFooterString, fontRegular, PdfPCell.ALIGN_RIGHT); } else { AddEmptyCell(table); } doc.Add(table); }