Click here to Skip to main content
12,350,653 members (24,870 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
Hi guys,

I'm trying to put a table in an absolute position, but i don't know if it's that possible.
If someone of you have any idea, just let me know.

Thanks a lot in advance.
Posted 21-Mar-12 4:42am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You can put each of your tables in an iTextSharp.text.Paragraph and use the Paragraph object's SpacingAfter property to create your gap. Sample code:
private static void DemoTableSpacing() { 
    using (FileStream fs = new FileStream("SpacingTest.pdf", FileMode.Create)) { 
 
        Document doc = new Document(); 
        PdfWriter.GetInstance(doc, fs); 
        doc.Open(); 
 
        Paragraph paragraphTable1 = new Paragraph(); 
        paragraphTable1.SpacingAfter = 15f; 
 
        PdfPTable table = new PdfPTable(3); 
        PdfPCell cell = new PdfPCell(new Phrase("This is table 1")); 
        cell.Colspan = 3; 
        cell.HorizontalAlignment = 1; 
        table.AddCell(cell); 
        table.AddCell("Col 1 Row 1"); 
        table.AddCell("Col 2 Row 1"); 
        table.AddCell("Col 3 Row 1"); 
        //table.AddCell("Col 1 Row 2"); 
        //table.AddCell("Col 2 Row 2"); 
        //table.AddCell("Col 3 Row 2"); 
        paragraphTable1.Add(table); 
        doc.Add(paragraphTable1); 
 
        Paragraph paragraphTable2 = new Paragraph(); 
        paragraphTable2.SpacingAfter = 10f; 
 
        table = new PdfPTable(3); 
        cell = new PdfPCell(new Phrase("This is table 2")); 
        cell.Colspan = 3; 
        cell.HorizontalAlignment = 1; 
        table.AddCell(cell); 
        table.AddCell("Col 1 Row 1"); 
        table.AddCell("Col 2 Row 1"); 
        table.AddCell("Col 3 Row 1"); 
        table.AddCell("Col 1 Row 2"); 
        table.AddCell("Col 2 Row 2"); 
        table.AddCell("Col 3 Row 2"); 
        paragraphTable2.Add(table); 
        doc.Add(paragraphTable2); 
        doc.Close(); 
    } 
} 
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160621.1 | Last Updated 21 Mar 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100