HtmlForm form = new HtmlForm();
form.Controls.Add(GridView2);
StringWriter sw = new StringWriter();
HtmlTextWriter hTextWriter = new HtmlTextWriter(sw);
form.Controls[0].RenderControl(hTextWriter);
string html = sw.ToString();
Document Doc = new Document();
PdfWriter.GetInstance(Doc, new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\GridView.pdf", FileMode.Create));
Doc.Open();
System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader(new StringReader(html));
HtmlParser.Parse(Doc, xmlReader); Doc.Close();
string Path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\GridView.pdf";
ShowPdf(Path);