title: gridview column width in itextsharp pdf WORKING needs styling
body: <p>This is working and opening the correct information in a pdf in a new window using itextsharp.
  But the first column is way too wide and the second, third, and fourth columns are too small.
  How do I style this?</p>
  
  <pre><code>&lt;form id="f1"&gt;
  &lt;asp:ImageButton BorderStyle="0" CssClass="submitbutton" runat="server" AlternateText="Get PDF" ID="LinkButton1" OnClick="btnGenerateReport" /&gt;
  
  &lt;asp:GridView BackColor="#FFFFFF" ID="gvEventCaf" runat="server" &gt;
  &lt;/asp:GridView&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is the codebehind for the get pdf onclick:</p>
  
  <pre><code>using System;
  using System.Data;
  using System.Configuration;
  using System.Collections;
  using System.Text;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.Security;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;
  using System.Web.UI.HtmlControls;
  using iTextSharp.text;
  using iTextSharp.text.pdf;
  using iTextSharp.text.html;
  using iTextSharp.text.html.simpleparser;
  using System.IO;
  
  protected void btnGenerateReport(object sender, EventArgs e)
  {
      MyPage tmpPage = new MyPage();
      HtmlForm form = new HtmlForm();
      form.Controls.Add(gvEventCaf);
      tmpPage.Controls.Add(form);
      StringWriter sw = new StringWriter();
      HtmlTextWriter htmlWriter = new HtmlTextWriter(sw);
      form.Controls[0].RenderControl(htmlWriter);
      string htmlContent = sw.ToString();
      Document document = new Document();
      // step 2:
      // we create a writer that listens to the document
      // and directs a PDF-stream to a file
      PdfWriter.GetInstance(document, new FileStream("c:\\users\\My\\Downloads\\Calendar.pdf", FileMode.Create));
  
      // step 3: we open the document
      document.Open();
  
      // step 4: we add a paragraph to the document
      //document.Add(new Paragraph(htmlContent.ToString()));
  
      System.Xml.XmlTextReader _xmlr = new System.Xml.XmlTextReader(new StringReader(htmlContent));
  
      HtmlParser.Parse(document, _xmlr);
  
      // step 5: we close the document
      document.Close();
  
      ShowPdf("c:\\users\\Me\\Downloads\\Calendar.pdf");
  
  }
  </code></pre>
  
  <p>And here's where I see the pdf:</p>
  
  <pre><code>private void ShowPdf(string s)
  {
      Response.ClearContent();
      Response.ClearHeaders();
      Response.AddHeader("Content-Disposition", "inline;filename=" + s);
      Response.ContentType = "application/pdf";
      Response.WriteFile(s);
      Response.Flush();
      Response.Clear();
  }
  </code></pre>
  
  <p>And here is the Mypage.cs helper file I put in App_Code:</p>
  
  <pre><code>using System;
  using System.Data;
  using System.Configuration;
  using System.Web;
  using System.Web.Security;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;
  using System.Web.UI.HtmlControls;
  
  /// &lt;summary&gt;
  /// Summary description for MyPage
  /// &lt;/summary&gt;
  public class MyPage : Page
  {
  public override void VerifyRenderingInServerForm(Control control)
  {
      GridView grid = control as GridView;
      if (grid != null &amp;&amp; grid.ID == "gvEventCaf")
          return;
      else
          base.VerifyRenderingInServerForm(control);
  
  }
  }
  </code></pre>