views:

640

answers:

2

I have a datatable containg address of users... I converted it to pdf using Itextsharp and now my requirement is i want to display one user's name,address in one column and another user's name and address in another column... In one row there must be two columns only how to do this using ItextSharp...

A: 

Should be just a matter of creating a PdfPTable object and configuring the widths such that each row has 2 columns.

http://www.mikesdotnetting.com/Article/86/iTextSharp-Introducing-Tables

A sample I made from previous code (haven't tried to compile it...)

iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 20, 20, 20, 20);
PdfPTable table;
PdfPCell cell;
iTextSharp.text.Paragraph paragraph;

table = new PdfPTable(2);
paragraph = new Paragraph();
paragraph.Add(new Chunk("TEXT", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.NORMAL)));
cell = new PdfPCell(paragraph);
cell.BorderWidth = 0;
cell.Padding = 0;
cell.PaddingTop = 12;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
table.AddCell(cell);
cell = new PdfPCell(paragraph);
cell.BorderWidth = 0;
cell.Padding = 0;
cell.PaddingTop = 12;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
table.AddCell(cell);
table.SetWidthPercentage(new float[2] { 460f, 140f }, PageSize.LETTER);
table.HorizontalAlignment = Element.ALIGN_CENTER;
document.Add(table);
Mayo
A: 

Thank You and definitely i ll give a try.....

Pandiya Chendur