Export DataTable to PDF Step 1 : Import the namespaces using iTextSharp.text; using iTextSharp.text.pdf; using iTextSharp.text.html; using iTextSharp.text.html.simpleparser; Step 2 : Add the Export Method public void ExportToPdf( DataTable dt) { Document document = new Document (); //string Filename = GetUniqueName(4); PdfWriter writer = PdfWriter .GetInstance(document, new FileStream (Server.MapPath( "PDF/testpdf.pdf" ), FileMode .Create)); document.Open(); //iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance("c://ggi logo.bmp"); //document.Add(img); iTextSharp.text. Font font5 = iTextSharp.text. FontFactory .GetFont( FontFactory .HELVETICA, 5); //float[] columnDefinitionSize = { 22F, 22F, 12F, 7.75F, 7.77F, 7.77F, 7.77F, 7.77F, 10.88F, 10.88F, 10.88F, 4.75F, 7.77F, 7.77F, 7.77F, 7.77F, 7.77F, 7.77F, 9F }; PdfPTable
ASP.NET || Javascript || Dataobject || Code Solutions Free Open Source code for Developers