Hi all, I need some help sorting out a formatting issue when creating an pdf.
Basically i'm creating a table, setting all the settings, then from a database going through each result and creating the cells to display the data. What I am doing is looping through the results, and each time adding 4 new cells to the table, which works perfectly fine, but if the results continue onto a new page, the first 2 rows or sets of cells overlap each other. Below is the code that generates the pdf document, the results are collected into an Arraylist of file objects. [code] try { PdfWriter writer = PdfWriter.GetInstance (basedoc, new FileStream(Server.MapPath("") + "/_files/" + IPAddress.Replace (".","") + ".pdf", FileMode.Create)); writer.SetEncryption (PdfWriter.STRENGTH40BITS, null, null, PdfWriter.AllowPrinting); basedoc.Open(); Font items_font = new Font(1, 10f); basedoc.Header = new HeaderFooter(new Phrase("File Review Report - ", items_font), new Phrase( " : " + DateTime.Now.ToShortDateString(), items_font)); Table main = new Table(4, 2); main.DefaultCellBorder = 0; main.Border = 0; main.Cellpadding = 0; main.Cellspacing = 0; main.Padding = 0; main.SetWidths(new int[4]{ 50, 300, 100, 75}); Font Header_Font = new Font(1, 20f); Font List_Font = new Font(1, 10f); Table Header = new Table(2); Header.DefaultCellBorder = 0; Header.Border = 0; Header.Cellpadding = 0; Header.Cellspacing = 0; Header.Padding = 0; Paragraph Paragraph_HDR_MainText = new Paragraph("File Review Report - " + AccountName, Header_Font); Paragraph Paragraph_HDR_SmallText = new Paragraph("Created: " + DateTime.Now.ToShortDateString(), List_Font); Cell Header_MainText = new Cell(); Header_MainText.Add (Paragraph_HDR_MainText); Header_MainText.Add (Paragraph_HDR_SmallText); iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(Server.MapPath("logo.gif")); logo.ScaleToFit(45f, 45f); logo.Alignment = iTextSharp.text.Image.ALIGN_RIGHT; Cell Header_Logo = new Cell(); Header_Logo.Add(logo); Header.AddCell(Header_MainText); Header.AddCell(Header_Logo); Paragraph spacer_content = new Paragraph ("s ", new Font(1, 20f, 1, iTextSharp.text.Color.WHITE)); Cell spacer = new Cell(spacer_content); spacer.Colspan = 4; main.AddCell(spacer); basedoc.Add(Header); Phrase header_1_phrase = new Phrase ("Barcode", List_Font); Cell header_1 = new Cell (header_1_phrase); Phrase header_2_phrase = new Phrase ("Reference", List_Font); Cell header_2 = new Cell (header_2_phrase); Phrase header_3_phrase = new Phrase (" Holder", List_Font); Cell header_3 = new Cell (header_3_phrase); Phrase header_4_phrase = new Phrase ("Review Date", List_Font); Cell header_4 = new Cell (header_4_phrase); main.AddCell(header_1); main.AddCell(header_2); main.AddCell(header_3); main.AddCell(header_4); Paragraph spacer_content1 = new Paragraph("s ", new Font(1, 5f, 1, iTextSharp.text.Color.WHITE)); Cell spacer1 = new Cell (spacer_content1); spacer1.BorderWidthBottom = 1; spacer1.Colspan = 4; main.AddCell(spacer1); Paragraph spacer_content2 = new Paragraph("s ", new Font(1, 5f, 1, iTextSharp.text.Color.WHITE)); Cell spacer2 = new Cell (spacer_content2); spacer2.Colspan =4; main.AddCell(spacer2); basedoc.Add(main); Table Data = new Table(4, 2); Data.DefaultCellBorder = 0; Data.Border = 0; Data.Cellpadding = 0; Data.Cellspacing = 0; Data.SetWidths(new int[4]{ 50, 300, 100, 75}); foreach(File found in Files) { Paragraph addp1; Paragraph addp2; Paragraph addp3; Paragraph addp4; addp1 = new Paragraph(found.ID, List_Font); addp2 = new Paragraph (found.Reference, List_Font); if(found.Holder == "holder") addp3 = new Paragraph (" n/a", List_Font); else addp3 = new Paragraph (" "+ found.Holder, List_Font); addp4 = new Paragraph (found.ReviewDate, List_Font); Cell addcell1 = new Cell(addp1); Cell addcell2 = new Cell(addp2); Cell addcell3 = new Cell(addp3); Cell addcell4 = new Cell(addp4); addcell1.HorizontalAlignment = Element.ALIGN_LEFT; addcell2.HorizontalAlignment = Element.ALIGN_JUSTIFIED; addcell3.HorizontalAlignment = Element.ALIGN_JUSTIFIED; addcell4.HorizontalAlignment = Element.ALIGN_RIGHT; Data.AddCell(addcell1); Data.AddCell(addcell2); Data.AddCell(addcell3); Data.AddCell(addcell4); } basedoc.Add(Data); basedoc.Close(); ReturnValue = "Yes"; [/code] Anyone? TIA Gav ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions