Atlast i itslef solved the Problem...:) :) :)
private void button1_Click(object sender, RoutedEventArgs e)
{
ExportPdf(pdftbl);
}
public void ExportPdf(DataTable dt)
{
Document document = new Document();
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("C://Bala//testpdf.pdf", FileMode.Create));
document.Open();
iTextSharp.text.Font font5 = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA, 5);
PdfPTable table = new PdfPTable(dt.Columns.Count);
PdfPRow row = null;
float[] widths = new float[] { 4f, 4f, 4f };
PdfPCell CellActext = new PdfPCell(new Phrase(new Chunk("Name", FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.GREEN))));
CellActext.Colspan = 1;
CellActext.Border = 0;
CellActext.HorizontalAlignment = Element.ALIGN_LEFT;
CellActext.BackgroundColor = new iTextSharp.text.Color(24, 150, 191);
table.AddCell(CellActext);
PdfPCell CellActext1 = new PdfPCell(new Phrase(new Chunk("Age", FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.ORANGE))));
CellActext1.Colspan = 1;
CellActext1.Border = 0;
CellActext1.HorizontalAlignment = Element.ALIGN_LEFT;
CellActext1.BackgroundColor = new iTextSharp.text.Color(25, 140, 181);
table.AddCell(CellActext1);
PdfPCell CellActext2 = new PdfPCell(new Phrase(new Chunk("SecondName", FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLUE))));
CellActext2.Colspan = 1;
CellActext2.Border = 0;
CellActext2.HorizontalAlignment = Element.ALIGN_LEFT;
CellActext2.BackgroundColor = new iTextSharp.text.Color(23, 130, 111);
table.AddCell(CellActext2);
table.SetWidths(widths);
table.WidthPercentage = 100;
int iCol = 0;
string colname = "";
foreach (DataColumn c in dt.Columns)
{
table.AddCell(new Phrase(c.ColumnName, font5));
}
foreach (DataRow r in dt.Rows)
{
if (dt.Rows.Count > 0)
{
table.AddCell(new Phrase(r[0].ToString(), font5));
table.AddCell(new Phrase(r[1].ToString(), font5));
table.AddCell(new Phrase(r[2].ToString(), font5));
}
}
document.Add(table);
document.Close();
}