Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=UserDetails.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
grdUOM.AllowPaging = false;
grdUOM.DataSource = (DataSet)(ViewState["pdf"]);
grdUOM.DataBind();
grdUOM.RenderControl(hw);
grdUOM.HeaderRow.Style.Add("width", "15%");
grdUOM.HeaderRow.Style.Add("font-size", "10px");
grdUOM.Style.Add("text-decoration", "none");
grdUOM.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
grdUOM.Style.Add("font-size", "8px");
StringReader sr = new StringReader(sw.ToString());
iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(PageSize.A4, 7f, 7f, 7f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
Above is my code for exporting my gridview to PDF.
Above screen shots are of the gridview and the PDF file, which is generated after. In the PDF screen shot, the alignment is totally distorted. What changes will I have to make in my above code to get the right table format in my PDF file?